You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/application-gateway/application-gateway-diagnostics.md
+69-26Lines changed: 69 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
1
---
2
2
title: Diagnostic logs
3
3
titleSuffix: Azure Application Gateway
4
-
description: Learn how to enable and manage logs for Azure Application Gateway
4
+
description: Learn how to enable and manage logs for Azure Application Gateway.
5
5
services: application-gateway
6
6
author: greg-lindsay
7
7
ms.service: application-gateway
8
8
ms.topic: article
9
-
ms.date: 02/28/2024
9
+
ms.date: 04/24/2024
10
10
ms.author: greglin
11
11
---
12
12
@@ -32,14 +32,56 @@ You can use different types of logs in Azure to manage and troubleshoot applicat
32
32
33
33
You have the following options to store the logs in your preferred location.
34
34
35
-
1.**Log Analytic workspace**: Recommended as it allows you to readily use the predefined queries, visualizations and set alerts based on specific log conditions.
36
-
1.**Azure Storage account**: Storage accounts are best used for logs when logs are stored for a longer duration and reviewed when needed.
37
-
1.**Azure Event Hubs**: Event hubs are a great option for integrating with other security information and event management (SIEM) tools to get alerts on your resources.
38
-
1.**Azure Monitor partner integrations**
35
+
**Log Analytic workspace**: This option allows you to readily use the predefined queries, visualizations, and set alerts based on specific log conditions. The tables used by resource logs in log analytics workspace depend on what type of collection the resource is using:
36
+
37
+
**Azure diagnostics**: Data is written to the [Azure Diagnostics table](/azure/azure-monitor/reference/tables/azurediagnostics). Azure Diagnostics table is shared between multiple resource type, with each of them adding their own custom fields. When number of custom fields ingested to Azure Diagnostics table exceeds 500, new fields aren't added as top level but added to "AdditionalFields" field as dynamic key value pairs.
39
38
40
-
[Learn more](../azure-monitor/essentials/diagnostic-settings.md?WT.mc_id=Portal-Microsoft_Azure_Monitoring&tabs=portal#destinations) about the Azure Monitor's Diagnostic settings destinations.
39
+
**Resource-specific(recommended)**: Data is written to dedicated tables for each category of the resource. In resource specific mode, each log category selected in the diagnostic setting is assigned its own table within the chosen workspace. This has several benefits, including:
40
+
- Easier data manipulation in log queries
41
+
- Improved discoverability of schemas and their structures
42
+
- Enhanced performance in terms of ingestion latency and query times
43
+
- The ability to assign [Azure role-based access control rights to specific tables](../azure-monitor/logs/manage-access.md?tabs=portal#set-table-level-read-access)
41
44
42
-
### Enable logging through PowerShell
45
+
For Application Gateway, resource specific mode creates three tables:
> The resource specific option is currently available in all **public regions**.<br>
52
+
> Existing users can continue using Azure Diagnostics, or can opt for dedicated tables by switching the toggle in Diagnostic settings to **Resource specific**, or to **Dedicated** in API destination. Dual mode isn't possible. The data in all the logs can either flow to Azure Diagnostics, or to dedicated tables. However, you can have multiple diagnostic settings where one data flow is to azure diagnostic and another is using resource specific at the same time.
53
+
54
+
**Selecting the destination table in Log analytics :** All Azure services eventually use the resource-specific tables. As part of this transition, you can select Azure diagnostic or resource specific table in the diagnostic setting using a toggle button. The toggle is set to **Resource specific** by default and in this mode, logs for new selected categories are sent to dedicated tables in Log Analytics, while existing streams remain unchanged. See the following example.
55
+
56
+
[](./media/application-gateway-diagnostics/resource-specific.png#lightbox)
57
+
58
+
**Workspace Transformations:** Opting for the Resource specific option allows you to filter and modify your data before it’s ingested with [workspace transformations](../azure-monitor/essentials/data-collection-transformations-workspace.md). This provides granular control, allowing you to focus on the most relevant information from the logs there by reducing data costs and enhancing security.
59
+
For detailed instructions on setting up workspace transformations, please refer:[Tutorial: Add a workspace transformation to Azure Monitor Logs by using the Azure portal](../azure-monitor/logs/tutorial-workspace-transformations-portal.md).
60
+
61
+
### Examples of optimizing access logs using Workspace Transformations
62
+
63
+
**Example 1: Selective Projection of Columns**: Imagine you have application gateway access logs with 20 columns, but you’re interested in analyzing data from only 6 specific columns. By using workspace transformation, you can project these 6 columns into your workspace, effectively excluding the other 14 columns. Even though the original data from those excluded columns won’t be stored, empty placeholders for them still appear in the Logs blade. This approach optimizes storage and ensures that only relevant data is retained for analysis.
64
+
65
+
> [!NOTE]
66
+
> Within the Logs blade, selecting the **Try New Log Analytics** option gives greater control over the columns displayed in your user interface.
67
+
68
+
**Example 2: Focusing on Specific Status Codes**: When analyzing access logs, instead of processing all log entries, you can write a query to retrieve only rows with specific HTTP status codes (such as 4xx and 5xx). Since most requests ideally fall under the 2xx and 3xx categories (representing successful responses), focusing on the problematic status codes narrows down the data set. This targeted approach allows you to extract the most relevant and actionable information, making it both beneficial and cost-effective.
69
+
70
+
**Recommended transition strategy to move from Azure diagnostic to resource specific table:**
71
+
1. Assess current data retention: Determine the duration for which data is presently retained in the Azure diagnostics table (for example: assume the diagnostics table retains data for 15 days).
72
+
2. Establish resource-specific retention: Implement a new Diagnostic setting with resource specific table.
73
+
3. Parallel data collection: For a temporary period, collect data concurrently in both the Azure Diagnostics and the resource-specific settings.
74
+
4. Confirm data accuracy: Verify that data collection is accurate and consistent in both settings.
75
+
5. Remove Azure diagnostics setting: Remove the Azure Diagnostic setting to prevent duplicate data collection.
76
+
77
+
Other storage locations:
78
+
-**Azure Storage account**: Storage accounts are best used for logs when logs are stored for a longer duration and reviewed when needed.
79
+
-**Azure Event Hubs**: Event hubs are a great option for integrating with other security information and event management (SIEM) tools to get alerts on your resources.
80
+
-**Azure Monitor partner integrations**.
81
+
82
+
Learn more about the Azure Monitor's [diagnostic settings destinations](../azure-monitor/essentials/diagnostic-settings.md?WT.mc_id=Portal-Microsoft_Azure_Monitoring&tabs=portal#destinations) .
83
+
84
+
## Enable logging through PowerShell
43
85
44
86
Activity logging is automatically enabled for every Resource Manager resource. You must enable access and performance logging to start collecting the data available through those logs. To enable logging, use the following steps:
45
87
@@ -61,7 +103,7 @@ Activity logging is automatically enabled for every Resource Manager resource. Y
61
103
> [!TIP]
62
104
>Activity logs do not require a separate storage account. The use of storage for access and performance logging incurs service charges.
63
105
64
-
### Enable logging through the Azure portal
106
+
## Enable logging through the Azure portal
65
107
66
108
1. In the Azure portal, find your resource and select **Diagnostic settings**.
67
109
@@ -81,15 +123,15 @@ Activity logging is automatically enabled for every Resource Manager resource. Y
81
123
82
124
5. Type a name for the settings, confirm the settings, and select **Save**.
83
125
84
-
### Activity log
126
+
## Activity log
85
127
86
128
Azure generates the activity log by default. The logs are preserved for 90 days in the Azure event logs store. Learn more about these logs by reading the [View events and activity log](../azure-monitor/essentials/activity-log.md) article.
87
129
88
-
### Access log
130
+
## Access log
89
131
90
132
The access log is generated only if you've enabled it on each Application Gateway instance, as detailed in the preceding steps. The data is stored in the storage account that you specified when you enabled the logging. Each access of Application Gateway is logged in JSON format as shown below.
91
133
92
-
#### For Application Gateway and WAF v2 SKU
134
+
### For Application Gateway and WAF v2 SKU
93
135
94
136
> [!NOTE]
95
137
> For TLS/TCP proxy related information, visit [data reference](monitor-application-gateway-reference.md#tlstcp-proxy-logs).
@@ -173,7 +215,7 @@ The access log is generated only if you've enabled it on each Application Gatewa
173
215
> [!Note]
174
216
>Access logs with clientIP value 127.0.0.1 originate from an internal security process running on the application gateway instances. You can safely ignore these log entries.
175
217
176
-
####For Application Gateway Standard and WAF SKU (v1)
218
+
### For Application Gateway Standard and WAF SKU (v1)
177
219
178
220
|Value |Description |
179
221
|---------|---------|
@@ -224,33 +266,34 @@ If the application gateway can't complete the request, it stores one of the foll
224
266
225
267
|4XX Errors | (The 4xx error codes indicate that there was an issue with the client's request, and the Application Gateway can't fulfill it.) |
226
268
|---------|---------|
227
-
| ERRORINFO_INVALID_METHOD| The client has sent a request which is non-RFC compliant. Possible reasons: client using HTTP method not supported by server, misspelled method, incompatible HTTP protocol version etc.|
269
+
| ERRORINFO_INVALID_METHOD| The client has sent a request which is non-RFC compliant. Possible reasons: client using HTTP method not supported by server, misspelled method, incompatible HTTP protocol version etc.|
228
270
| ERRORINFO_INVALID_REQUEST | The server can't fulfill the request because of incorrect syntax.|
229
271
| ERRORINFO_INVALID_VERSION| The application gateway received a request with an invalid or unsupported HTTP version.|
230
272
| ERRORINFO_INVALID_09_METHOD| The client sent request with HTTP Protocol version 0.9.|
231
-
| ERRORINFO_INVALID_HOST |The value provided in the "Host" header is either missing, improperly formatted, or doesn't match the expected host value (when there is no Basic listener, and none of the hostnames of Multisite listeners match with the host).|
273
+
| ERRORINFO_INVALID_HOST |The value provided in the "Host" header is either missing, improperly formatted, or doesn't match the expected host value. For example, when there's no Basic listener, and none of the hostnames of Multisite listeners match with the host.|
232
274
| ERRORINFO_INVALID_CONTENT_LENGTH | The length of the content specified by the client in the content-Length header doesn't match the actual length of the content in the request.|
233
-
| ERRORINFO_INVALID_METHOD_TRACE | The client sent HTTP TRACE method which is not supported by the application gateway.|
234
-
| ERRORINFO_CLIENT_CLOSED_REQUEST | The client closed the connection with the application gateway before the idle timeout period elapsed.Check whether the client timeout period is greater than the [idle timeout period](./application-gateway-faq.yml#what-are-the-settings-for-keep-alive-timeout-and-tcp-idle-timeout) for the application gateway.|
275
+
| ERRORINFO_INVALID_METHOD_TRACE | The client sent HTTP TRACE method, which isn't supported by the application gateway.|
276
+
| ERRORINFO_CLIENT_CLOSED_REQUEST | The client closed the connection with the application gateway before the idle timeout period elapsed.Check whether the client timeout period is greater than the [idle timeout period](./application-gateway-faq.yml#what-are-the-settings-for-keep-alive-timeout-and-tcp-idle-timeout) for the application gateway.|
235
277
| ERRORINFO_REQUEST_URI_INVALID |Indicates issue with the Uniform Resource Identifier (URI) provided in the client's request. |
236
278
| ERRORINFO_HTTP_NO_HOST_HEADER | Client sent a request without Host header. |
237
279
| ERRORINFO_HTTP_TO_HTTPS_PORT |The client sent a plain HTTP request to an HTTPS port. |
238
-
| ERRORINFO_HTTPS_NO_CERT | Indicates client is not sending a valid and properly configured TLS certificate during Mutual TLS authentication. |
280
+
| ERRORINFO_HTTPS_NO_CERT | Indicates client isn't sending a valid and properly configured TLS certificate during Mutual TLS authentication. |
239
281
240
282
241
283
|5XX Errors | Description |
242
284
|---------|---------|
243
285
| ERRORINFO_UPSTREAM_NO_LIVE | The application gateway is unable to find any active or reachable backend servers to handle incoming requests |
244
286
| ERRORINFO_UPSTREAM_CLOSED_CONNECTION | The backend server closed the connection unexpectedly or before the request was fully processed. This could happen due to backend server reaching its limits, crashing etc.|
245
287
| ERRORINFO_UPSTREAM_TIMED_OUT | The established TCP connection with the server was closed as the connection took longer than the configured timeout value. |
246
-
### Performance log
247
288
248
-
The performance log is generated only if you have enabled it on each Application Gateway instance, as detailed in the preceding steps. The data is stored in the storage account that you specified when you enabled the logging. The performance log data is generated in 1-minute intervals. It is available only for the v1 SKU. For the v2 SKU, use [Metrics](application-gateway-metrics.md) for performance data. The following data is logged:
289
+
## Performance log
290
+
291
+
The performance log is generated only if you have enabled it on each Application Gateway instance, as detailed in the preceding steps. The data is stored in the storage account that you specified when you enabled the logging. The performance log data is generated in 1-minute intervals. It's available only for the v1 SKU. For the v2 SKU, use [Metrics](application-gateway-metrics.md) for performance data. The following data is logged:
249
292
250
293
251
294
|Value |Description |
252
295
|---------|---------|
253
-
|instanceId | Application Gateway instance for which performance data is being generated. For a multiple-instance application gateway, there is one row per instance. |
296
+
|instanceId | Application Gateway instance for which performance data is being generated. For a multiple-instance application gateway, there's one row per instance. |
254
297
|healthyHostCount | Number of healthy hosts in the backend pool. |
255
298
|unHealthyHostCount | Number of unhealthy hosts in the backend pool. |
256
299
|requestCount | Number of requests served. |
@@ -280,14 +323,14 @@ The performance log is generated only if you have enabled it on each Application
280
323
> [!NOTE]
281
324
> Latency is calculated from the time when the first byte of the HTTP request is received to the time when the last byte of the HTTP response is sent. It's the sum of the Application Gateway processing time plus the network cost to the back end, plus the time that the back end takes to process the request.
282
325
283
-
###Firewall log
326
+
## Firewall log
284
327
285
328
The firewall log is generated only if you have enabled it for each application gateway, as detailed in the preceding steps. This log also requires that the web application firewall is configured on an application gateway. The data is stored in the storage account that you specified when you enabled the logging. The following data is logged:
286
329
287
330
288
331
|Value |Description |
289
332
|---------|---------|
290
-
|instanceId | Application Gateway instance for which firewall data is being generated. For a multiple-instance application gateway, there is one row per instance. |
333
+
|instanceId | Application Gateway instance for which firewall data is being generated. For a multiple-instance application gateway, there's one row per instance. |
291
334
|clientIp | Originating IP for the request. |
292
335
|clientPort | Originating port for the request. |
293
336
|requestUri | URL of the received request. |
@@ -337,14 +380,14 @@ The firewall log is generated only if you have enabled it for each application g
337
380
}
338
381
```
339
382
340
-
###View and analyze the activity log
383
+
## View and analyze the activity log
341
384
342
385
You can view and analyze activity log data by using any of the following methods:
343
386
344
387
***Azure tools**: Retrieve information from the activity log through Azure PowerShell, the Azure CLI, the Azure REST API, or the Azure portal. Step-by-step instructions for each method are detailed in the [Activity operations with Resource Manager](../azure-monitor/essentials/activity-log.md) article.
345
388
***Power BI**: If you don't already have a [Power BI](https://powerbi.microsoft.com/pricing) account, you can try it for free. By using the [Power BI template apps](/power-bi/service-template-apps-overview), you can analyze your data.
346
389
347
-
###View and analyze the access, performance, and firewall logs
390
+
## View and analyze the access, performance, and firewall logs
348
391
349
392
[Azure Monitor logs](/previous-versions/azure/azure-monitor/insights/azure-networking-analytics) can collect the counter and event log files from your Blob storage account. It includes visualizations and powerful search capabilities to analyze your logs.
350
393
@@ -355,7 +398,7 @@ You can also connect to your storage account and retrieve the JSON log entries f
355
398
>
356
399
>
357
400
358
-
####Analyzing Access logs through GoAccess
401
+
### Analyzing Access logs through GoAccess
359
402
360
403
We have published a Resource Manager template that installs and runs the popular [GoAccess](https://goaccess.io/) log analyzer for Application Gateway Access Logs. GoAccess provides valuable HTTP traffic statistics such as Unique Visitors, Requested Files, Hosts, Operating Systems, Browsers, HTTP Status codes and more. For more details, please see the [Readme file in the Resource Manager template folder in GitHub](https://github.com/Azure/azure-quickstart-templates/tree/master/demos/application-gateway-logviewer-goaccess).
0 commit comments