{"id":1451,"date":"2023-04-02T18:29:59","date_gmt":"2023-04-02T17:29:59","guid":{"rendered":"https:\/\/mortenknudsen.net\/?p=1451"},"modified":"2023-04-03T11:52:29","modified_gmt":"2023-04-03T10:52:29","slug":"009-collecting-iis-logs-using-azure-monitor-agent","status":"publish","type":"post","link":"https:\/\/mortenknudsen.net\/?p=1451","title":{"rendered":"Collecting IIS logs using Azure Monitor Agent"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">This blog will give you insight on how to setup collection o<strong>f IIS logs<\/strong> from <strong>Windows devices<\/strong> using <strong>Azure Monitor Agent (AMA).<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This blog-post is part of a series of blog posts to <a href=\"https:\/\/mortenknudsen.net\/?p=1687\" target=\"_blank\" rel=\"noreferrer noopener\">master Azure logging in depth (overview)<\/a>. <\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized is-style-default\"><a href=\"https:\/\/mortenknudsen.net\/?p=1687\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-25.png\" alt=\"\" class=\"wp-image-2124\" width=\"434\" height=\"502\" srcset=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-25.png 867w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-25-259x300.png 259w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-25-768x889.png 768w\" sizes=\"auto, (max-width: 434px) 100vw, 434px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To get you started, you can find <a href=\"https:\/\/github.com\/KnudsenMorten\/AzureLogLibrary\" target=\"_blank\" rel=\"noreferrer noopener\">ARM-templates &amp; scripts in my AzureLogLibrary (github)<\/a>. Details will be covered in the articles.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><a href=\"https:\/\/github.com\/KnudsenMorten\/AzureLogLibarary\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-26-1024x466.png\" alt=\"\" class=\"wp-image-2125\" width=\"400\" height=\"182\" srcset=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-26-1024x466.png 1024w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-26-300x137.png 300w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-26-768x349.png 768w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-26.png 1057w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><br><\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Quick Links<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"#arm\">How to start collecting SecurityEvent using ARM-template ?<\/a><br><a href=\"#gui\">How to setup in GUI<\/a><br><a href=\"#architecture\">High-level architecture \/ flow<\/a><br><a href=\"#tutorial\">Tutorial \u2013 How to make data transformations using Data Collection Rules?<\/a><br><a href=\"https:\/\/mortenknudsen.net\/?p=1440#architecture\">Data transformation architecture<\/a><br><a href=\"https:\/\/mortenknudsen.net\/?p=1440#steps\">High-level steps to do data transformation<\/a><br><a href=\"https:\/\/mortenknudsen.net\/?p=1440#step1\">Step 1: Kusto command must be defined<\/a><br><a href=\"https:\/\/mortenknudsen.net\/?p=1440#escape\">Escape characters in advanced queries<\/a><br><a href=\"https:\/\/mortenknudsen.net\/?p=1440#step2\">Step 2: Deploy a new DCR<\/a><br><a href=\"https:\/\/mortenknudsen.net\/?p=1440#azlogdcringestps\">Step 3a: Data transformation using AzLogIngestPS<\/a><br><a href=\"https:\/\/mortenknudsen.net\/?p=1440#rest\">Step 3b: Adding the TransformKql using REST API and Powershell (alternative method)<\/a><br><a href=\"https:\/\/mortenknudsen.net\/?p=1440#verify\">Step 4: Verification of changes in DCR (optional)<\/a><br><a href=\"https:\/\/mortenknudsen.net\/?p=1440#associate\">Step 5: Associate the DCR rule to the machine(s)<\/a><br><a href=\"https:\/\/mortenknudsen.net\/?p=1440#reallife\">Real-life examples of effect of transformations<\/a><br><a href=\"https:\/\/mortenknudsen.net\/?p=1440#example1\">Example 1 \u2013 removing specific SecurityEvent (5145) from a particular server<\/a><br><a href=\"https:\/\/mortenknudsen.net\/?p=1440#example2\">Example 2 \u2013 removing syslog traffic<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"arm\">How to start collecting IIS-logs using ARM-template ?<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">You can check out the ARM-templates on <a href=\"https:\/\/github.com\/KnudsenMorten\/AzureLogLibrary\" target=\"_blank\" rel=\"noreferrer noopener\">my Github<\/a><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><a href=\"https:\/\/raw.githubusercontent.com\/KnudsenMorten\/AzureLogLibrary\/main\/DataCollection\/iis-logs\/dce-iis-logs.json\" target=\"_blank\" rel=\"noreferrer noopener\">IIS-logs &#8211; DCE (step 1<\/a>)<\/td><\/tr><tr><td><a href=\"https:\/\/raw.githubusercontent.com\/KnudsenMorten\/AzureLogLibrary\/main\/DataCollection\/iis-logs\/dcr-windows-vmhealth-iis-logs-W3SVCx.json\" target=\"_blank\" rel=\"noreferrer noopener\">IIS-logs &#8211; DCR (step 2)<\/a><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/github.com\/KnudsenMorten\/AzureLogLibrary\" target=\"_blank\" rel=\"noreferrer noopener\">I do also provide more documentation and powershell script to deploy more DCRs<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I am also providing &#8216;Deploy to Azure&#8217; shortcuts, based on the mentioned ARM-templates so you can deploy samples into your environment.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">IIS-logs | Deploy DCE to Azure (step 1)<\/h2>\n\n\n\n<a href=\"https:\/\/portal.azure.com\/#create\/Microsoft.Template\/uri\/https%3A%2F%2Fraw.githubusercontent.com%2FKnudsenMorten%2FAzureLogLibrary%2Fmain%2FDataCollection%2Fiis-logs%2Fdce-iis-logs.json\" target=\"_blank\" rel=\"noopener\">\n  <img decoding=\"async\" src=\"https:\/\/aka.ms\/deploytoazurebutton\">\n<\/a>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">IIS-logs | Deploy DCR-rule to Azure (step 2)<\/h2>\n\n\n\n<a href=\"https:\/\/portal.azure.com\/#create\/Microsoft.Template\/uri\/https%3A%2F%2Fraw.githubusercontent.com%2FKnudsenMorten%2FAzureLogLibrary%2Fmain%2FDataCollection%2Fiis-logs%2Fdcr-windows-vmhealth-iis-logs-W3SVCx.json\" target=\"_blank\" rel=\"noopener\">\n  <img decoding=\"async\" src=\"https:\/\/aka.ms\/deploytoazurebutton\">\n<\/a>\n\n\n\n<p class=\"wp-block-paragraph\"><br><\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"gui\">How to setup in GUI ?<\/h1>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"847\" height=\"1024\" src=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/dcr-create-1-847x1024.png\" alt=\"\" class=\"wp-image-1847\" srcset=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/dcr-create-1-847x1024.png 847w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/dcr-create-1-248x300.png 248w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/dcr-create-1-768x929.png 768w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/dcr-create-1.png 979w\" sizes=\"auto, (max-width: 847px) 100vw, 847px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"541\" height=\"231\" src=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/dcr-create-2.png\" alt=\"\" class=\"wp-image-1848\" srcset=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/dcr-create-2.png 541w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/dcr-create-2-300x128.png 300w\" sizes=\"auto, (max-width: 541px) 100vw, 541px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"704\" src=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-15-1024x704.png\" alt=\"\" class=\"wp-image-2042\" srcset=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-15-1024x704.png 1024w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-15-300x206.png 300w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-15-768x528.png 768w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-15.png 1116w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"369\" src=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-16-1024x369.png\" alt=\"\" class=\"wp-image-2043\" srcset=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-16-1024x369.png 1024w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-16-300x108.png 300w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-16-768x276.png 768w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-16-1536x553.png 1536w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-16.png 1589w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"architecture\">High-level architecture \/ flow<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">All data will be sent into the Azure LogAnalytics standard table, <strong>W3CIISLog<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"799\" src=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-11-1024x799.png\" alt=\"\" class=\"wp-image-1899\" srcset=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-11-1024x799.png 1024w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-11-300x234.png 300w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-11-768x599.png 768w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-11.png 1205w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The flow is different, as the DCR tells the <strong>AMA extension<\/strong> to sent the data to a <strong>custom table<\/strong> (Custom-MyTable_CL). Then data is transformed (streamed) into the standard table,<strong> W3CIISLog<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As the data comes into a custom log table initially, we need to have a DCE configured. DCR handles the transformation into the standard table.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">DCR contains the following <strong>dataSources<\/strong> section.<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>\"dataSources\": {\n            \"iisLogs\": &#91;\n                {\n                    \"streams\": &#91;\n                        \"Microsoft-W3CIISLog\"\n                    ],\n                    \"logDirectories\": &#91;\n                        \"C:\\\\inetpub\\\\logs\\\\LogFiles\\\\W3SVC1\"\n                    ],\n                    \"name\": \"iisLogsDataSource\"\n                }\n            ]<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>{\n    \"properties\": {\n        \"description\": \"Data collection rule for IIS logs\",\n        \"immutableId\": \"dcr-9631dbaa01214d26b3181772965ae715\",\n        \"dataCollectionEndpointId\": \"\/subscriptions\/xxxxxxxx8-bf1701b862c3\/resourceGroups\/rg-azmon-datacollectionendpoints-p\/providers\/Microsoft.Insights\/dataCollectionEndpoints\/dce-iis-logs-westeurope\",\n        \"streamDeclarations\": {\n            \"Custom-MyTable_CL\": {\n                \"columns\": &#91;\n                    {\n                        \"name\": \"TimeGenerated\",\n                        \"type\": \"datetime\"\n                    },\n                    {\n                        \"name\": \"RawData\",\n                        \"type\": \"string\"\n                    }\n                ]\n            }\n        },\n        \"dataSources\": {\n            \"iisLogs\": &#91;\n                {\n                    \"streams\": &#91;\n                        \"Microsoft-W3CIISLog\"\n                    ],\n                    \"logDirectories\": &#91;\n                        \"C:\\\\inetpub\\\\logs\\\\LogFiles\\\\W3SVC1\"\n                    ],\n                    \"name\": \"iisLogsDataSource\"\n                }\n            ]\n        },\n        \"destinations\": {\n            \"logAnalytics\": &#91;\n                {\n                    \"workspaceResourceId\": \"\/subscriptions\/fce4f282-fcc6-43fb-94d8-bf1701b862c3\/resourcegroups\/rg-logworkspaces\/providers\/microsoft.operationalinsights\/workspaces\/log-platform-management-srvnetworkcloud-p\",\n                    \"workspaceId\": \"b7d80924-d55d-4bf6-b2b3-9889301c7114\",\n                    \"name\": \"DataCollectionIISlogs\"\n                }\n            ]\n        },\n        \"dataFlows\": &#91;\n            {\n                \"streams\": &#91;\n                    \"Microsoft-W3CIISLog\"\n                ],\n                \"destinations\": &#91;\n                    \"DataCollectionIISlogs\"\n                ],\n                \"transformKql\": \"source\",\n                \"outputStream\": \"Microsoft-W3CIISLog\"\n            }\n        ],\n        \"provisioningState\": \"Succeeded\"\n    }<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><br><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"tutorial\">Tutorial \u2013 How to make data transformations using Data Collection Rules?<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">The below text is embedded from another <a href=\"https:\/\/mortenknudsen.net\/?p=1440\" target=\"_blank\" rel=\"noreferrer noopener\">blog post<\/a><\/p>\n\n\n<div data-post-id=\"1440\" class=\"insert-page insert-page-1440 \">\n<p class=\"wp-block-paragraph\">This section will show you the <strong>steps<\/strong> for setting up data transformations &#8211; and <strong>how you can do the transformation<\/strong> using <strong><a href=\"https:\/\/github.com\/KnudsenMorten\/AzLogDcrIngestPS\" target=\"_blank\" rel=\"noreferrer noopener\">AzLogDcrIngestPS<\/a><\/strong> (my new Powershell module) &#8211; or using <strong>REST API commands in Powershell<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you want to read about transformation in depth, <a href=\"https:\/\/mortenknudsen.net\/?p=1433&amp;#Data-transformation\" target=\"_blank\" rel=\"noreferrer noopener\">you can find more details here<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can also get inspired of real-life samples (and their effects) of using transformation to reduce costs.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"quick\">Quick Links<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"#architecture\">Data transformation architecture<\/a><br><a href=\"#steps\">High-level steps to do data transformation<\/a><br><a href=\"#step1\">Step 1: Kusto command must be defined<\/a><br><a href=\"#escape\">Escape characters in advanced queries<\/a><br><a href=\"#step2\">Step 2: Deploy a new DCR<\/a><br><a href=\"#azlogdcringestps\">Step 3a: Data transformation using AzLogIngestPS<\/a><br><a href=\"#rest\">Step 3b: Adding the TransformKql using REST API and Powershell (alternative method)<\/a><br><a href=\"#verify\">Step 4: Verification of changes in DCR (optional)<\/a><br><a href=\"#associate\">Step 5: Associate the DCR rule to the machine(s)<\/a><br><a href=\"#reallife\">Real-life examples of effect of transformations<\/a><br><a href=\"#example1\">Example 1 &#8211; removing specific SecurityEvent (5145) from a particular server<\/a><br><a href=\"#example2\">Example 2 &#8211; removing syslog traffic<\/a><br><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"architecture\">Data transformation architecture<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Data transformations runs in the <strong>Azure Data Ingestion Pipeline<\/strong> and happens very fast as data is being uploaded.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"315\" src=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/transformation-1-1024x315.png\" alt=\"\" class=\"wp-image-1795\" srcset=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/transformation-1-1024x315.png 1024w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/transformation-1-300x92.png 300w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/transformation-1-768x236.png 768w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/transformation-1-1536x473.png 1536w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/transformation-1-2048x630.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Data transformations are defined in the <strong>transformKq<\/strong>l property in the DCR section <strong>dataFlows<\/strong>.<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>dataFlows\": [\n            {\n                \"streams\": [\n                    \"Microsoft-SecurityEvent\"\n                ],\n                \"destinations\": [\n                    \"DataCollectionEvent\"\n                ],\n               <strong> \"transformKql\": \"source | where (EventID != 8002) and (EventID != 5058) and (EventID != 4662) \",<\/strong>\n                \"outputStream\": \"Microsoft-SecurityEvent\"\n            }<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"steps\">High-level steps to do data transformation<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">The 5 steps to add a data transformations are:<\/p>\n\n\n\n<ol class=\"wp-block-list\" type=\"1\">\n<li>Kusto command must be defined to understand the syntax to exclude the data<\/li>\n\n\n\n<li>Deploy a new DCR<\/li>\n\n\n\n<li>Add the <strong>transformKql<\/strong> to the DCR &#8211; I am covering 2 methods for this in the article (AzLogIngestPS and REST API)<\/li>\n\n\n\n<li>Verification of changes in DCR (optional)<\/li>\n\n\n\n<li>Assign the DCR to the machine(s) where the transformation must happen<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the example below, I am doing a transformation to remove data. Another example is to add new columns, based on incoming data. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I hope the below example gives you the insight to understand how to work with transformation.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step1\">Step 1: Kusto command must be defined<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Transformations defines which data should be sent through the pipeline. <\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">If you want to exclude specific events, you will instruct the transformation to exclude these events using standard Kusto &#8211; except you will refer to the tablename as <strong>source<\/strong> <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>source where (EventID != 4662)<\/strong><\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Below are 4 samples<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>SecurityEvent | where EventID != 5145<\/td><td>Here I want to see all Security event except for EventID = 5145<\/td><\/tr><tr><td>SecurityEvent | where (EventID != 8002) and (EventID != 5058) and (EventID != 4662)<\/td><td>Here I want to see all Security events except for EventID = 8002,5058,4662<\/td><\/tr><tr><td>Event | where ( (EventID != 10016 and EventLog == \u201cApplication\u201d)&nbsp; )<\/td><td>Here I want to see all Event system and application events, except for application events with eventid 10016<\/td><\/tr><tr><td>CommonSecurityLog | where (DeviceVendor !contains \u201csonicwall\u201d) or ((DeviceVendor contains \u201csonicwall\u201d) and (Activity contains \u201cconnection opened\u201d or Activity contains \u201cconnection closed\u201d) and (Protocol != \u201cudp\/dns\u201d))<\/td><td>Here I want to see all CEF\/syslog where devicevendor is different from sonicwall like Cisco and all sonicwall events, except if protocol is udp\/dns<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\"><br><\/figcaption><\/figure>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">Since the transformation is applied to each record individually, it can\u2019t use any KQL operators that act on multiple records. Only operators that take a single row as input and return no more than one row are supported. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example,&nbsp;<a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/data-explorer\/kusto\/query\/summarizeoperator\">summarize<\/a>&nbsp;isn\u2019t supported since it summarizes multiple records. See&nbsp;<a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/azure-monitor\/essentials\/data-collection-transformations-structure#supported-kql-features\">Supported KQL features<\/a>&nbsp;for a complete list of supported features.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Therefore you cannot use cross-workspace references like doing lookup in another table.<\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When the Kusto command is working as expected, then change the tablename to <strong>source<\/strong>.<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>SecurityEvent | where EventID != 5145<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">was changed to<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>source | where EventID != 5145<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"escape\">Escape characters in advanced queries<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If you need to work with advanced queries, it can be required to adjust the query with escape characters:<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>SecurityEvent | where (Account != \u201cWINSFTP\\\\autotest\u201d) and (EventID != 4688 and EventID != 8002 and EventID != 4625) and (Account != \u201cWORKGROUP\\\\WINSFTP$\u201d)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">will be changed to<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>source\\r\\n| where (Account != \\\u201dCVT-WINSFTP\\\\\\\\cvtautotest\\\u201d) and (EventID != 4688 and EventID != 8002 and EventID != 4625) and (Account != \\\u201dWORKGROUP\\\\\\\\CVT-WINSFTP$\\\u201d)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Using online converter<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In case you are working with advanced queries, I prefer to take my Kusto query and paste it in an online converter, which will convert the query with escape characters.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Personally, I use the online website&nbsp;<a href=\"https:\/\/jsonformatter.org\/json-escape\">https:\/\/jsonformatter.org\/json-escape<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step2\">Step 2: Deploy a new DCR<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Configure a standard DCR rule and choose to collect what you want like for example all security events or all system and application events.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Make a note of the <strong>ResourceId<\/strong> of the DCR rule. You will use the ResourceId in step 3<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"2099\" height=\"348\" src=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2022\/12\/resid.jpg\" alt=\"\" class=\"wp-image-78\" srcset=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2022\/12\/resid.jpg 2099w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2022\/12\/resid-300x50.jpg 300w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2022\/12\/resid-1024x170.jpg 1024w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2022\/12\/resid-768x127.jpg 768w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2022\/12\/resid-1536x255.jpg 1536w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2022\/12\/resid-2048x340.jpg 2048w\" sizes=\"auto, (max-width: 2099px) 100vw, 2099px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"162\" src=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2022\/12\/resourceid-1024x162.jpg\" alt=\"\" class=\"wp-image-77\" srcset=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2022\/12\/resourceid-1024x162.jpg 1024w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2022\/12\/resourceid-300x48.jpg 300w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2022\/12\/resourceid-768x122.jpg 768w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2022\/12\/resourceid.jpg 1425w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"azlogdcringestps\">Step 3a: Data transformation using AzLogIngestPS<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">It is very easy to work with transformations using my powershell module, <strong>AzLogIngestPS<\/strong>. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can <a href=\"https:\/\/github.com\/KnudsenMorten\/AzLogDcrIngestPS\" target=\"_blank\" rel=\"noreferrer noopener\">read about my powershell module, AzLogIngestPS here<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To get started viewing an existing transformation, you will only require the ResourceId, which was noted in the previous step 2.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can view an existing data transformations (transformKql) using the function <strong>Get-AzDataCollectionRuleTransformKql<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>Get-AzDataCollectionRuleTransformKql  -DcrResourceID &lt;DCR resourceid&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Here you can see value of the transformKql marked in bold (source &#8230;.)<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>PS &gt; Get-AzDataCollectionRuleTransformKql -DcrResourceId \/subscriptions\/fxxxxx4d8-bf1701b862c3\/resourceGroups\/rg-logworkspaces\/providers\/microsoft.insights\/dataCollectionRules\/dcr-ingest-exclude-security-eventid\n<strong>source | where (EventID != 8002) and (EventID != 5058) and (EventID != 4662) and (EventID != 4688)<\/strong><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can add a transformation to an existing DCR using the function <strong>Update-AzDataCollectionRuleTransformKql<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>Update-AzDataCollectionRuleTransformKql -DcrResourceId &lt;DCR-ID&gt; -transformKql  &lt;transform-KQL&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Here you can see the value <strong>before <\/strong>and <strong>after<\/strong> updating the transformation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Value before<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>PS &gt; Get-AzDataCollectionRuleTransformKql -DcrResourceId \/subscriptions\/fce4f282-fcc6-43fb-94d8-bf1701b862c3\/resourceGroups\/rg-logworkspaces\/providers\/microsoft.insights\/dataCollectionRules\/dcr-ingest-exclude-security-eventid\nsource | where (EventID != 8002) and (EventID != 5058) and (EventID != 4662) and (EventID != 4688)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Adding the transformation<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>PS &gt; <strong>Update-AzDataCollectionRuleTransformKql -DcrResourceId \/subscriptions\/xxxxxx-43fb-94d8-bf1701b862c3\/resourceGroups\/rg-logworkspaces\/providers\/microsoft.insights\/dataCollectionRules\/dcr-ingest-exclude-security-eventid -transformKql  \"source | where (EventID != 8002) and (EventID != 5058) and (EventID != 4662) and (EventID != 4688) and (EventID != 4663)\"<\/strong>\n\nUpdating transformKql for DCR\n\/subscriptions\/xxxxxfb-94d8-bf1701b862c3\/resourceGroups\/rg-logworkspaces\/providers\/microsoft.insights\/dataCollectionRules\/dcr-ingest-exclude-security-eventid<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Value after &#8211; note &#8220;<strong>and (EventID != 4663)<\/strong>&#8221; has been added compared to before value<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>PS &gt; Get-AzDataCollectionRuleTransformKql -DcrResourceId \/subscriptions\/xxxxx3fb-94d8-bf1701b862c3\/resourceGroups\/rg-logworkspaces\/providers\/microsoft.insights\/dataCollectionRules\/dcr-ingest-exclude-security-eventid\n<strong>source | where (EventID != 8002) and (EventID != 5058) and (EventID != 4662) and (EventID != 4688) and (EventID != 4663)<\/strong><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can install <strong>AzLogDcrIngestPS<\/strong> from <strong>Powershell gallery<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>install-module AzLogIngestPS<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You need to connect to Azure first with an account with RBAC permissions.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PS &gt; Connect-AzAccount<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><br><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"rest\">Step 3b: Adding the TransformKql using REST API and Powershell (alternative method)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">As an alternative to using AzLogIngestPS, you can also call REST API and add the <strong>transformKql<\/strong> command.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">TransformKql requires a REST API call to <strong>minimum api-version 2021-09-01-preview<\/strong>. You can see the syntax below.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Currently, the recommended API is <strong>2022-06-01<\/strong>. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can see available API version in the GUI.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"255\" src=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-13-1024x255.png\" alt=\"\" class=\"wp-image-2019\" srcset=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-13-1024x255.png 1024w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-13-300x75.png 300w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-13-768x191.png 768w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-13.png 1511w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"252\" src=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-14-1024x252.png\" alt=\"\" class=\"wp-image-2020\" srcset=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-14-1024x252.png 1024w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-14-300x74.png 300w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-14-768x189.png 768w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-14.png 1527w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><br><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The steps to add a transformation to an existing DCR are:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Retrieve the entire DCR using REST API (GET) in JSON format &#8211; and save it to a TXT file<\/li>\n\n\n\n<li>Edit the file &#8211; and add the <strong>transformKql<\/strong> parameter in the <strong>dataFlow<\/strong> section<\/li>\n\n\n\n<li>Upload the entire file content using REST API (PUT)<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I have provided a <a href=\"https:\/\/github.com\/KnudsenMorten\/Azure_LogAnalytics_Data_Transformation.git\" target=\"_blank\" rel=\"noreferrer noopener\">Powershell script on my github<\/a> to retrieve the DCR into a flat JSON-file so you can edit the file and add the needed transformation \u2013 and then upload the modified DCR again. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Below I have created a sample folder C:\\TMP where the file will be stored<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Start by setting the variables $ResourceId and $FilePath<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">ResourceId was noted in the previous step 2<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">FilePath can be any path \u2013 it is only a temporary file used for this change as example<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>####################################################\n# VARIABLES\n####################################################\n\n# here you put the ResourceID of the Data Collection Rules (a sample is provided below)\n$ResourceId = \"\/subscriptions\/xxxxxx\/resourceGroups\/rg-logworkspaces\/providers\/microsoft.insights\/dataCollectionRules\/dcr-ingest-exclude-security-eventid\"\n    \n# here you put a path and file name where you want to store the temporary file-extract from DCR (a sample is provided below)\n$FilePath   = \"c:\\tmp\\dcr-ingest-exclude-security-eventid.txt\"\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Connect to Azure<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>####################################################\n# CONNECT TO AZURE\n####################################################\n\nConnect-AzAccount<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Run the export DCR<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>$DCR = Invoke-AzRestMethod -Path (\"$ResourceId\"+\"?api-version=2022-06-01\") -Method GET\n\n$DCR.Content | ConvertFrom-Json | ConvertTo-Json -Depth 20 | Out-File -FilePath $FilePath\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now you have a JSON file in c:\\tmp folder<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Modify file and add TransformKql<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Open the file using your favorite editor and add the line <strong>transformKql<\/strong> command that you created in step 1<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code><strong>\"transformKql\":&nbsp; \"source\\n| where (EventID != 5145)\"<\/strong>,<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">NOTE: Remember to add the , (comma) at the end of the line so you are not breaking the JSON syntax.<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>\"dataFlows\": [\n            {\n                \"streams\": [\n                    \"Microsoft-SecurityEvent\"\n                ],\n                \"destinations\": [\n                    \"DataCollectionEvent\"\n                ],\n                <strong>\"transformKql\": \"source | where (EventID != 8002) and (EventID != 4688) and (EventID != 4663)\",<\/strong>\n                \"outputStream\": \"Microsoft-SecurityEvent\"\n            }\n        ],<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Upload the modified DCR (overwrite)<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now you want to run the last part of the powershell script, which will update the DCR taking the entire content of the local file and making PUT REST call against the specific api version <strong>2022-06-01<\/strong>. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>####################################################\n# UPLOAD FILE \/ UPDATE DCR WITH TRANSFORM\n####################################################\n\n$DCRContent = Get-Content $FilePath -Raw \n\nInvoke-AzRestMethod -Path (\"$ResourceId\"+\"?api-version=2022-06-01\") -Method PUT -Payload $DCRContent\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You should be getting a StatusCode 200 with the PUT commmand, indicating everything it updated correctly<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"75\" src=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2022\/12\/ok-1024x75.jpg\" alt=\"\" class=\"wp-image-81\" srcset=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2022\/12\/ok-1024x75.jpg 1024w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2022\/12\/ok-300x22.jpg 300w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2022\/12\/ok-768x56.jpg 768w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2022\/12\/ok-1536x113.jpg 1536w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2022\/12\/ok.jpg 1759w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If there is is an error in the file structure, you will get an error 400<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"88\" src=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2022\/12\/error-1024x88.jpg\" alt=\"\" class=\"wp-image-82\" srcset=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2022\/12\/error-1024x88.jpg 1024w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2022\/12\/error-300x26.jpg 300w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2022\/12\/error-768x66.jpg 768w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2022\/12\/error-1536x131.jpg 1536w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2022\/12\/error.jpg 1778w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"verify\">Step 4: Verification of changes in DCR (optional)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You can choose to check in the GUI for the change. Remember to choose the API-version 2022-06-01 (or 2021-09-01-preview). Otherwise you wont be able to see the change. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"255\" src=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-13-1024x255.png\" alt=\"\" class=\"wp-image-2019\" srcset=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-13-1024x255.png 1024w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-13-300x75.png 300w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-13-768x191.png 768w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-13.png 1511w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"252\" src=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-14-1024x252.png\" alt=\"\" class=\"wp-image-2020\" srcset=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-14-1024x252.png 1024w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-14-300x74.png 300w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-14-768x189.png 768w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-14.png 1527w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You will now see the transformKql.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can also extract the changes running the first lines again to extract into the local file using the GET command<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>####################################################\n# EXPORT EXISTING DCR TO FILE\n####################################################\n\n$DCR = Invoke-AzRestMethod -Path (\"$ResourceId\"+\"?api-version=2022-06-01\") -Method GET\n\n$DCR.Content | ConvertFrom-Json | ConvertTo-Json -Depth 20 | Out-File -FilePath $FilePath\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"associate\">Step 5: Associate the DCR rule to the machine(s)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Lastly you have to associate the DCR rule to the machine(s) where you want the transformation to happen.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"351\" src=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/DCR-associate-1024x351.png\" alt=\"\" class=\"wp-image-1806\" srcset=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/DCR-associate-1024x351.png 1024w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/DCR-associate-300x103.png 300w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/DCR-associate-768x263.png 768w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/DCR-associate.png 1529w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You have to wait for pipeline transformation to happen. Normally it will start within 5 minutes, sometimes a little longer.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><br><\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"reallife\">Real-life examples of effect of transformations<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Below you can find some examples and their effect of using transformations &#8211; with focus on cost reductions. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As you can see, the results were a significant decrease.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Of course there is a trade-off, which must be considered. There are always 2 sides of the coin \u2013 will I miss the data at some point !<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"example1\">Example 1 &#8211; removing specific SecurityEvent (5145) from a particular server<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"752\" height=\"74\" src=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/transformation-sample2.png\" alt=\"\" class=\"wp-image-1808\" srcset=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/transformation-sample2.png 752w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/transformation-sample2-300x30.png 300w\" sizes=\"auto, (max-width: 752px) 100vw, 752px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/transformation-sample3.png\" alt=\"\" class=\"wp-image-1809\" width=\"539\" height=\"100\" srcset=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/transformation-sample3.png 539w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/transformation-sample3-300x56.png 300w\" sizes=\"auto, (max-width: 539px) 100vw, 539px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"251\" src=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/transformation-sample1-1024x251.png\" alt=\"\" class=\"wp-image-1807\" srcset=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/transformation-sample1-1024x251.png 1024w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/transformation-sample1-300x74.png 300w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/transformation-sample1-768x188.png 768w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/transformation-sample1-1536x377.png 1536w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/transformation-sample1.png 1546w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The effect in cost &#8211; here shown in DKK, where the daily cost drops to DKK 2300 from DKK 5000<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"368\" src=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/transformation-sample4-1024x368.png\" alt=\"\" class=\"wp-image-1810\" srcset=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/transformation-sample4-1024x368.png 1024w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/transformation-sample4-300x108.png 300w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/transformation-sample4-768x276.png 768w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/transformation-sample4-1536x551.png 1536w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/transformation-sample4.png 1995w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"example2\">Example 2 &#8211; removing syslog traffic<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Here is an example where I did a transformation removing <strong>Syslog events<\/strong> with specific patterns.<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>source\n| where (DeviceVendor !contains \"sonicwall\") or ((DeviceVendor contains \"sonicwall\") and (Activity contains \"connection opened\" or Activity contains \"connection closed\") and (Protocol != \"udp\/dns\"))<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"517\" src=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/workspace-transformation-example-1024x517.png\" alt=\"\" class=\"wp-image-1783\" srcset=\"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/workspace-transformation-example-1024x517.png 1024w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/workspace-transformation-example-300x151.png 300w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/workspace-transformation-example-768x388.png 768w, https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/workspace-transformation-example.png 1349w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>This blog will give you insight on how to setup collection of IIS logs from Windows devices using Azure Monitor &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Collecting IIS logs using Azure Monitor Agent\" class=\"read-more button\" href=\"https:\/\/mortenknudsen.net\/?p=1451#more-1451\" aria-label=\"Read more about Collecting IIS logs using Azure Monitor Agent\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":1899,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"ngg_post_thumbnail":0,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[140,55,59,129,131,61,128,54,143,141,57,130,28,139,136,138,137,142,133,134,146,60,132,58,145,135,144],"tags":[],"class_list":["post-1451","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ama","category-azure","category-azure-arc","category-azure-data-collection-rules","category-azure-data-ingestion-pipeline","category-azure-extensions","category-azure-log-ingestion-api","category-azure-loganalytics","category-azure-logging","category-azure-monitor-agent","category-azure-security","category-clientinspector","category-community","category-data-collection-endpoint","category-data-transformation","category-dce","category-dcr","category-logging","category-microsoft-security","category-mvpbuzz","category-performance-collection","category-scripting","category-security","category-sentinel","category-servicemap","category-transformation","category-vminsight","infinite-scroll-item","resize-featured-image"],"featured_image_src":"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-11.png","author_info":{"display_name":"Morten Knudsen","author_link":"https:\/\/mortenknudsen.net\/?author=1"},"jetpack_featured_media_url":"https:\/\/mortenknudsen.net\/wp-content\/uploads\/2023\/04\/image-11.png","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/mortenknudsen.net\/index.php?rest_route=\/wp\/v2\/posts\/1451","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mortenknudsen.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mortenknudsen.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mortenknudsen.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mortenknudsen.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1451"}],"version-history":[{"count":17,"href":"https:\/\/mortenknudsen.net\/index.php?rest_route=\/wp\/v2\/posts\/1451\/revisions"}],"predecessor-version":[{"id":2145,"href":"https:\/\/mortenknudsen.net\/index.php?rest_route=\/wp\/v2\/posts\/1451\/revisions\/2145"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mortenknudsen.net\/index.php?rest_route=\/wp\/v2\/media\/1899"}],"wp:attachment":[{"href":"https:\/\/mortenknudsen.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1451"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mortenknudsen.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1451"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mortenknudsen.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1451"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}