Skip to content

Commit 0490583

Browse files
Merge pull request #195265 from bwren/iis-log
Add IIS to text logs
2 parents 6325659 + 8b36b58 commit 0490583

File tree

2 files changed

+113
-23
lines changed

2 files changed

+113
-23
lines changed

articles/azure-monitor/agents/data-collection-text-log.md

Lines changed: 112 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,26 @@
11
---
2-
title: Collect text logs with Azure Monitor agent (preview)
2+
title: Collect text and IIS logs with Azure Monitor agent (preview)
33
description: Configure collection of filed-based text logs using a data collection rule on virtual machines with the Azure Monitor agent.
44
ms.topic: conceptual
5-
ms.date: 04/08/2022
5+
ms.date: 04/15/2022
66

77
---
88

9-
# Collect text logs with Azure Monitor agent (preview)
10-
This tutorial shows you how to configure the collection of file-based text logs with the [Azure Monitor agent](azure-monitor-agent-overview.md) and sending the collected data to a custom table in a Log Analytics workspace. This feature uses a [data collection rule](../essentials/data-collection-rule-overview.md) that you can use to define the structure of the log file and its target table.
9+
# Collect text and IIS logs with Azure Monitor agent (preview)
10+
This article describes how to configure the collection of file-based text logs, including logs generated by IIS on Windows computers, with the [Azure Monitor agent](azure-monitor-agent-overview.md). Many applications log information to text files instead of standard logging services such as Windows Event log or Syslog.
1111

1212
> [!NOTE]
1313
> This feature is currently in public preview and isn't completely implemented in the Azure portal. This tutorial uses Azure Resource Manager templates for steps that can't yet be performed with the portal.
1414
15-
In this tutorial, you learn to:
16-
17-
> [!div class="checklist"]
18-
> * Create a custom table in a Log Analytics workspace.
19-
> * Create a data collection endpoint to receive data from an agent.
20-
> * Create a data collection rule that collects data from both a custom text log file.
21-
> * Create an association to apply the data collection rule to agents.
2215
## Prerequisites
23-
To complete this tutorial, you need the following:
16+
To complete this procedure, you need the following:
2417

2518
- Log Analytics workspace where you have at least [contributor rights](../logs/manage-access.md#manage-access-using-azure-permissions) .
2619
- [Permissions to create Data Collection Rule objects](/azure/azure-monitor/essentials/data-collection-rule-overview#permissions) in the workspace.
2720
- An agent with supported log file as described in the next section.
2821

2922
## Log files supported
30-
The log file must meet the following criteria to be collected by this feature:
23+
IIS logs must be in W3C format. Other log files must meet the following criteria to be collected:
3124

3225
- The log file must be stored on a local drive of a virtual machine, virtual machine scale set, or Arc enabled server with the Azure Monitor installed.
3326
- Each entry in the log file must be delineated with an [ISO 8601 formatted](https://www.iso.org/standard/40874.html) time stamp or an end of line.
@@ -37,15 +30,18 @@ The log file must meet the following criteria to be collected by this feature:
3730
## Steps to collect text logs
3831
The steps to configure log collection are as follows. The detailed steps for each are provided in the sections below:
3932

40-
1. Create a new table in your workspace to receive the collected data.
33+
1. Create a new table in your workspace to receive the collected data. (not required for IIS logs)
4134
2. Create a data collection endpoint for the Azure Monitor agent to connect.
4235
3. Create a data collection rule to define the structure of the log file and destination of the collected data.
4336
4. Create association between the data collection rule and the agent collecting the log file.
4437

4538
## Create new table in Log Analytics workspace
4639
The custom table must be created before you can send data to it. When you create the table, you provide its name and a definition for each of its columns.
4740

48-
Use the **Tables - Update** API to create the table with the PowerShell code below. This code creates a table called *MyTable_CL* with two columns. You can modify this schema to collect a different table.
41+
>[!NOTE]
42+
> This step isn't required to collect an IIS log. The table [W3CIISLog](/azure/azure-monitor/reference/tables/w3ciislog) will be used for IIS logs.
43+
44+
Use the **Tables - Update** API to create the table with the PowerShell code below. This code creates a table called *MyTable_CL* with two columns. Modify this schema to collect a different table.
4945

5046
> [!IMPORTANT]
5147
> Custom tables must use a suffix of *_CL*.
@@ -96,7 +92,6 @@ A [data collection endpoint (DCE)](../essentials/data-collection-endpoint-overvi
9692
9793
:::image type="content" source="../logs/media/tutorial-ingestion-time-transformations-api/edit-template.png" lightbox="../logs/media/tutorial-ingestion-time-transformations-api/edit-template.png" alt-text="Screenshot that shows portal blade to edit Resource Manager template.":::
9894
99-
10095
```json
10196
{
10297
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
@@ -143,6 +138,7 @@ A [data collection endpoint (DCE)](../essentials/data-collection-endpoint-overvi
143138
}
144139
```
145140
141+
146142
4. On the **Custom deployment** screen, specify a **Subscription** and **Resource group** to store the data collection rule and then provide values a **Name** for the data collection endpoint. The **Location** should be the same location as the workspace. The **Region** will already be populated and is used for the location of the data collection endpoint.
147143
148144
:::image type="content" source="../logs/media/tutorial-ingestion-time-transformations-api/custom-deployment-values.png" lightbox="../logs/media/tutorial-ingestion-time-transformations-api/custom-deployment-values.png" alt-text="Screenshot that shows portal blade to edit custom deployment values for data collection endpoint.":::
@@ -173,19 +169,18 @@ The [data collection rule (DCR)](../essentials/data-collection-rule-overview.md)
173169
174170
:::image type="content" source="../logs/media/tutorial-ingestion-time-transformations-api/build-custom-template.png" lightbox="../logs/media/tutorial-ingestion-time-transformations-api/build-custom-template.png" alt-text="Screenshot that shows portal blade to build template in the editor.":::
175171
176-
3. Paste the Resource Manager template below into the editor and then change the following values:
177-
178-
You may choose to modify the following details in the DCR defined in this template:
172+
3. Paste one of the Resource Manager templates below into the editor and then change the following values:
179173
180174
- `streamDeclarations`: Defines the columns of the incoming data. This must match the structure of the log file.
181175
- `filePatterns`: Specifies the location and file pattern of the log files to collect. This defines a separate pattern for Windows and Linux agents.
182-
- `transformKql`: Specifies a [transformation](../logs/../essentials/data-collection-rule-transformations.md) to apply to the incoming data before it's sent to the workspace. Since data collection rules for Azure Monitor agent don't yet support transformations, this value will always be `source`.
176+
- `transformKql`: Specifies a [transformation](../logs/../essentials/data-collection-rule-transformations.md) to apply to the incoming data before it's sent to the workspace. Data collection rules for Azure Monitor agent don't yet support transformations, so this value should currently be `source`.
183177
184178
185179
4. Click **Save**.
186180
187181
:::image type="content" source="../logs/media/tutorial-ingestion-time-transformations-api/edit-template.png" lightbox="../logs/media/tutorial-ingestion-time-transformations-api/edit-template.png" alt-text="Screenshot that shows portal blade to edit Resource Manager template.":::
188182
183+
**Data collection rule for text log**
189184
190185
```json
191186
{
@@ -235,7 +230,7 @@ The [data collection rule (DCR)](../essentials/data-collection-rule-overview.md)
235230
"name": "[parameters('dataCollectionRuleName')]",
236231
"location": "[parameters('location')]",
237232
"apiVersion": "2021-09-01-preview",
238-
"properties": {
233+
"properties": {
239234
"dataCollectionEndpointId": "[parameters('endpointResourceId')]",
240235
"streamDeclarations": {
241236
"Custom-MyLogFileFormat": {
@@ -283,7 +278,6 @@ The [data collection rule (DCR)](../essentials/data-collection-rule-overview.md)
283278
},
284279
"name": "myLogFileFormat-Linux"
285280
}
286-
287281
]
288282
},
289283
"destinations": {
@@ -318,6 +312,102 @@ The [data collection rule (DCR)](../essentials/data-collection-rule-overview.md)
318312
}
319313
```
320314
315+
**Data collection rule for IIS log**
316+
317+
```json
318+
{
319+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
320+
"contentVersion": "1.0.0.0",
321+
"parameters": {
322+
"dataCollectionRuleName": {
323+
"type": "string",
324+
"metadata": {
325+
"description": "Specifies the name of the Data Collection Rule to create."
326+
}
327+
},
328+
"location": {
329+
"type": "string",
330+
"defaultValue": "westus2",
331+
"allowedValues": [
332+
"westus2",
333+
"eastus2",
334+
"eastus2euap"
335+
],
336+
"metadata": {
337+
"description": "Specifies the location in which to create the Data Collection Rule."
338+
}
339+
},
340+
"workspaceName": {
341+
"type": "string",
342+
"metadata": {
343+
"description": "Name of the Log Analytics workspace to use."
344+
}
345+
},
346+
"workspaceResourceId": {
347+
"type": "string",
348+
"metadata": {
349+
"description": "Specifies the Azure resource ID of the Log Analytics workspace to use."
350+
}
351+
},
352+
"endpointResourceId": {
353+
"type": "string",
354+
"metadata": {
355+
"description": "Specifies the Azure resource ID of the Data Collection Endpoint to use."
356+
}
357+
}
358+
},
359+
"resources": [
360+
{
361+
"type": "Microsoft.Insights/dataCollectionRules",
362+
"name": "[parameters('dataCollectionRuleName')]",
363+
"location": "[parameters('location')]",
364+
"apiVersion": "2021-09-01-preview",
365+
"properties": {
366+
"dataCollectionEndpointId": "[parameters('endpointResourceId')]",
367+
"dataSources": {
368+
"iisLogs": [
369+
{
370+
"streams": [
371+
"Microsoft-W3CIISLog"
372+
],
373+
"logDirectories": [
374+
"C:\\inetpub\\logs\\LogFiles\\*.log"
375+
],
376+
"name": "myIisLogsDataSource"
377+
}
378+
]
379+
},
380+
"destinations": {
381+
"logAnalytics": [
382+
{
383+
"workspaceResourceId": "[parameters('workspaceResourceId')]",
384+
"name": "[parameters('workspaceName')]"
385+
}
386+
]
387+
},
388+
"dataFlows": [
389+
{
390+
"streams": [
391+
"Microsoft-W3CIISLog"
392+
],
393+
"destinations": [
394+
"[parameters('workspaceName')]"
395+
],
396+
"transformKql": "source"
397+
}
398+
]
399+
}
400+
}
401+
],
402+
"outputs": {
403+
"dataCollectionRuleId": {
404+
"type": "string",
405+
"value": "[resourceId('Microsoft.Insights/dataCollectionRules', parameters('dataCollectionRuleName'))]"
406+
}
407+
}
408+
}
409+
```
410+
321411
5. On the **Custom deployment** screen, specify a **Subscription** and **Resource group** to store the data collection rule and then provide values defined in the template. This includes a **Name** for the data collection rule and the **Workspace Resource ID** and **Endpoint Resource ID**. The **Location** should be the same location as the workspace. The **Region** will already be populated and is used for the location of the data collection rule.
322412
323413
:::image type="content" source="media/data-collection-text-log/custom-deployment-values.png" lightbox="media/data-collection-text-log/custom-deployment-values.png" alt-text="Screenshot that shows portal blade to edit custom deployment values for data collection rule.":::

articles/azure-monitor/toc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ items:
502502
- name: Collect events and performance
503503
displayName: data collection rule,Azure Monitor agent
504504
href: agents/data-collection-rule-azure-monitor-agent.md
505-
- name: Collect text Logs
505+
- name: Collect text and IIS Logs
506506
displayName: data collection rule,Azure Monitor agent
507507
href: agents/data-collection-text-log.md
508508
- name: Use data collection endpoints

0 commit comments

Comments
 (0)