Skip to content

Commit 6416893

Browse files
authored
Merge pull request #273265 from greg-lindsay/appgw-morleyan
Replace PR 272911
2 parents f6f6502 + 6fd031e commit 6416893

File tree

2 files changed

+69
-26
lines changed

2 files changed

+69
-26
lines changed

articles/application-gateway/application-gateway-diagnostics.md

Lines changed: 69 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
22
title: Diagnostic logs
33
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.
55
services: application-gateway
66
author: greg-lindsay
77
ms.service: application-gateway
88
ms.topic: article
9-
ms.date: 02/28/2024
9+
ms.date: 04/24/2024
1010
ms.author: greglin
1111
---
1212

@@ -32,14 +32,56 @@ You can use different types of logs in Azure to manage and troubleshoot applicat
3232

3333
You have the following options to store the logs in your preferred location.
3434

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.
3938

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)
4144

42-
### Enable logging through PowerShell
45+
For Application Gateway, resource specific mode creates three tables:
46+
* [AGWAccessLogs](/azure/azure-monitor/reference/tables/agwaccesslogs)
47+
* [AGWPerformanceLogs](/azure/azure-monitor/reference/tables/agwperformancelogs)
48+
* [AGWFirewallLogs](/azure/azure-monitor/reference/tables/agwfirewalllogs)
49+
50+
> [!NOTE]
51+
> 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+
[![Screenshot of the resource ID for application gateway in the portal.](./media/application-gateway-diagnostics/resource-specific.png)](./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
4385

4486
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:
4587

@@ -61,7 +103,7 @@ Activity logging is automatically enabled for every Resource Manager resource. Y
61103
> [!TIP]
62104
>Activity logs do not require a separate storage account. The use of storage for access and performance logging incurs service charges.
63105
64-
### Enable logging through the Azure portal
106+
## Enable logging through the Azure portal
65107
66108
1. In the Azure portal, find your resource and select **Diagnostic settings**.
67109
@@ -81,15 +123,15 @@ Activity logging is automatically enabled for every Resource Manager resource. Y
81123
82124
5. Type a name for the settings, confirm the settings, and select **Save**.
83125
84-
### Activity log
126+
## Activity log
85127
86128
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.
87129
88-
### Access log
130+
## Access log
89131
90132
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.
91133
92-
#### For Application Gateway and WAF v2 SKU
134+
### For Application Gateway and WAF v2 SKU
93135
94136
> [!NOTE]
95137
> 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
173215
> [!Note]
174216
>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.
175217
176-
#### For Application Gateway Standard and WAF SKU (v1)
218+
### For Application Gateway Standard and WAF SKU (v1)
177219

178220
|Value |Description |
179221
|---------|---------|
@@ -224,33 +266,34 @@ If the application gateway can't complete the request, it stores one of the foll
224266

225267
|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.) |
226268
|---------|---------|
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.|
228270
| ERRORINFO_INVALID_REQUEST | The server can't fulfill the request because of incorrect syntax.|
229271
| ERRORINFO_INVALID_VERSION| The application gateway received a request with an invalid or unsupported HTTP version.|
230272
| 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.|
232274
| 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.|
235277
| ERRORINFO_REQUEST_URI_INVALID |Indicates issue with the Uniform Resource Identifier (URI) provided in the client's request. |
236278
| ERRORINFO_HTTP_NO_HOST_HEADER | Client sent a request without Host header. |
237279
| 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. |
239281

240282

241283
|5XX Errors | Description |
242284
|---------|---------|
243285
| ERRORINFO_UPSTREAM_NO_LIVE | The application gateway is unable to find any active or reachable backend servers to handle incoming requests |
244286
| 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.|
245287
| 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
247288

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:
249292

250293

251294
|Value |Description |
252295
|---------|---------|
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. |
254297
|healthyHostCount | Number of healthy hosts in the backend pool. |
255298
|unHealthyHostCount | Number of unhealthy hosts in the backend pool. |
256299
|requestCount | Number of requests served. |
@@ -280,14 +323,14 @@ The performance log is generated only if you have enabled it on each Application
280323
> [!NOTE]
281324
> 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.
282325
283-
### Firewall log
326+
## Firewall log
284327

285328
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:
286329

287330

288331
|Value |Description |
289332
|---------|---------|
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. |
291334
|clientIp | Originating IP for the request. |
292335
|clientPort | Originating port for the request. |
293336
|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
337380
}
338381
```
339382

340-
### View and analyze the activity log
383+
## View and analyze the activity log
341384

342385
You can view and analyze activity log data by using any of the following methods:
343386

344387
* **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.
345388
* **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.
346389

347-
### View and analyze the access, performance, and firewall logs
390+
## View and analyze the access, performance, and firewall logs
348391

349392
[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.
350393

@@ -355,7 +398,7 @@ You can also connect to your storage account and retrieve the JSON log entries f
355398
>
356399
>
357400
358-
#### Analyzing Access logs through GoAccess
401+
### Analyzing Access logs through GoAccess
359402

360403
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).
361404

118 KB
Loading

0 commit comments

Comments
 (0)