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
description: Learn how to use Azure Application Insights with Azure Functions to monitor function executions.
3
+
description: Learn how to use Azure Application Insights with Azure Functions to monitor function executions. Application Insights collects log, performance, and error data.
4
4
ms.assetid: 501722c3-f2f7-4224-a220-6d59da08a320
5
5
ms.topic: conceptual
6
-
ms.date: 07/05/2022
6
+
ms.date: 05/07/2025
7
7
ms.custom: devx-track-csharp, fasttrack-edit
8
8
# Customer intent: As a developer, I want to understand what facilities are provided to help me monitor my functions so I can know if they're running correctly.
9
9
---
10
10
11
11
# Monitor executions in Azure Functions
12
12
13
-
[Azure Functions](functions-overview.md) offers built-in integration with [Azure Application Insights](/azure/azure-monitor/app/app-insights-overview) to monitor functions executions. This article provides an overview of the monitoring capabilities provided by Azure for monitoring Azure Functions.
13
+
[Azure Functions](functions-overview.md) offers built-in integration with Azure Application Insights to monitor functions executions. This article provides an overview of the monitoring capabilities provided by Azure for monitoring Azure Functions.
14
14
15
-
Application Insights collects log, performance, and error data. By automatically detecting performance anomalies and featuring powerful analytics tools, you can more easily diagnose issues and better understand how your functions are used. These tools are designed to help you continuously improve performance and usability of your functions. You can even use Application Insights during local function app project development. For more information, see [What is Application Insights?](/azure/azure-monitor/app/app-insights-overview).
15
+
Application Insights collects log, performance, and error data. By automatically detecting performance anomalies and featuring powerful analytics tools, you can more easily diagnose issues and better understand how your functions are used. These tools are designed to help you continuously improve performance and usability of your functions. You can even use Application Insights during local function app project development. For more information, see [Introduction to Application Insights](/azure/azure-monitor/app/app-insights-overview).
16
16
17
17
As Application Insights instrumentation is built into Azure Functions, you need a valid instrumentation key to connect your function app to an Application Insights resource. The instrumentation key is added to your application settings as you create your function app resource in Azure. If your function app doesn't already have this key, you can [set it manually](configure-monitoring.md#enable-application-insights-integration).
18
18
19
-
You can also monitor the function app itself by using Azure Monitor. To learn more, see [Monitoring Azure Functions with Azure Monitor](monitor-functions.md).
19
+
You can also monitor the function app itself by using Azure Monitor. To learn more, see [Monitor Azure Functions](monitor-functions.md).
20
20
21
21
## Application Insights pricing and limits
22
22
23
23
You can try out Application Insights integration with Azure Functions for free featuring a daily limit to how much data is processed for free.
24
24
25
-
If you enable Applications Insights during development, you might hit this limit during testing. Azure provides portal and email notifications when you're approaching your daily limit. If you miss those alerts and hit the limit, new logs won't appear in Application Insights queries. Be aware of the limit to avoid unnecessary troubleshooting time. For more information, see [Application Insights billing](/azure/azure-monitor/logs/cost-logs#application-insights-billing).
25
+
If you enable Applications Insights during development, you might hit this limit during testing. Azure provides portal and email notifications when you're approaching your daily limit. If you miss those alerts and hit the limit, new logs don't appear in Application Insights queries. Be aware of the limit to avoid unnecessary troubleshooting time. For more information, see [Application Insights billing](/azure/azure-monitor/logs/cost-logs#application-insights-billing).
26
26
27
27
> [!IMPORTANT]
28
28
> Application Insights has a [sampling](/azure/azure-monitor/app/sampling) feature that can protect you from producing too much telemetry data on completed executions at times of peak load. Sampling is enabled by default. If you appear to be missing data, you might need to adjust the sampling settings to fit your particular monitoring scenario. To learn more, see [Configure sampling](configure-monitoring.md#configure-sampling).
@@ -37,9 +37,9 @@ Typically, you create an Application Insights instance when you create your func
37
37
38
38
The following table details the supported features of Application Insights available for monitoring your function apps:
\* To enable the collection of SQL query string text, see [Enable SQL query collection](./configure-monitoring.md#enable-sql-query-collection).
67
67
68
68
## Collecting telemetry data
69
69
70
-
With Application Insights integration enabled, telemetry data is sent to your connected Application Insights instance. This data includes logs generated by the Functions host, traces written from your functions code, and performance data.
70
+
With Application Insights integration enabled, telemetry data is sent to your connected Application Insights instance. This data includes logs generated by the Functions host, traces written from your functions code, and performance data.
71
71
72
72
>[!NOTE]
73
-
>In addition to data from your functions and the Functions host, you can also collect data from the [Functions scale controller](#scale-controller-logs).
73
+
>In addition to data from your functions and the Functions host, you can also collect data from the [Functions scale controller](#scale-controller-logs).
74
74
75
75
### Log levels and categories
76
76
@@ -90,71 +90,70 @@ In [C#](functions-dotnet-class-library.md#log-custom-telemetry-in-c-functions),
90
90
91
91
Starting with version 2.x of Functions, Application Insights automatically collects data on dependencies for bindings that use certain client SDKs. Application Insights collects data on the following dependencies:
92
92
93
-
+ Azure Cosmos DB
94
-
+ Azure Event Hubs
95
-
+ Azure Service Bus
96
-
+ Azure Storage services (Blob, Queue, and Table)
93
+
- Azure Cosmos DB
94
+
- Azure Event Hubs
95
+
- Azure Service Bus
96
+
- Azure Storage services (Blob, Queue, and Table)
97
97
98
98
HTTP requests and database calls using `SqlClient` are also captured. For the complete list of dependencies supported by Application Insights, see [automatically tracked dependencies](/azure/azure-monitor/app/asp-net-dependencies#automatically-tracked-dependencies).
99
99
100
100
Application Insights generates an _application map_ of collected dependency data. The following is an example of an application map of an HTTP trigger function with a Queue storage output binding.
101
101
102
-

102
+
:::image type="content" source="./media/functions-monitoring/app-map.png" alt-text="Screenshot shows an application map with dependency in the Azure portal.":::
103
103
104
-
Dependencies are written at the `Information` level. If you filter at `Warning` or above, you won't see the dependency data. Also, automatic collection of dependencies happens at a non-user scope. To capture dependency data, make sure the level is set to at least `Information` outside the user scope (`Function.<YOUR_FUNCTION_NAME>.User`) in your host.
104
+
Dependencies are written at the `Information` level. If you filter at `Warning` or above, you don't see the dependency data. Also, automatic collection of dependencies happens at a non-user scope. To capture dependency data, make sure the level is set to at least `Information` outside the user scope (`Function.<YOUR_FUNCTION_NAME>.User`) in your host.
105
105
106
106
In addition to automatic dependency data collection, you can also use one of the language-specific Application Insights SDKs to write custom dependency information to the logs. For an example how to write custom dependencies, see one of the following language-specific examples:
107
107
108
-
+[Log custom telemetry in C# functions](functions-dotnet-class-library.md#log-custom-telemetry-in-c-functions)
109
-
+[Log custom telemetry in JavaScript functions](functions-reference-node.md#track-custom-data)
110
-
+[Log custom telemetry in Python functions](functions-reference-python.md#log-custom-telemetry)
108
+
-[Log custom telemetry in C# functions](functions-dotnet-class-library.md#log-custom-telemetry-in-c-functions)
109
+
-[Log custom telemetry in JavaScript functions](functions-reference-node.md#track-custom-data)
110
+
-[Log custom telemetry in Python functions](functions-reference-python.md#log-custom-telemetry)
111
111
112
112
### Performance Counters
113
113
114
114
Automatic collection of Performance Counters isn't supported when running on Linux.
115
115
116
-
## Writing to logs
116
+
## Writing to logs
117
117
118
-
The way that you write to logs and the APIs you use depend on the language of your function app project.
119
-
See the developer guide for your language to learn more about writing logs from your functions.
118
+
The way that you write to logs and the APIs you use depend on the language of your function app project. See the developer guide for your language to learn more about writing logs from your functions.
120
119
121
-
+[C# (.NET class library)](functions-dotnet-class-library.md#logging)
By default, the data collected from your function app is stored in Application Insights. In the [Azure portal](https://portal.azure.com), Application Insights provides an extensive set of visualizations of your telemetry data. You can drill into error logs and query events and metrics. To learn more, including basic examples of how to view and query your collected data, see [Analyze Azure Functions telemetry in Application Insights](analyze-telemetry-data.md).
128
+
By default, the data collected from your function app is stored in Application Insights. In the [Azure portal](https://portal.azure.com), Application Insights provides an extensive set of visualizations of your telemetry data. You can drill into error logs and query events and metrics. To learn more, including basic examples of how to view and query your collected data, see [Analyze Azure Functions telemetry in Application Insights](analyze-telemetry-data.md).
130
129
131
130
## Streaming Logs
132
131
133
132
While developing an application, you often want to see what's being written to the logs in near real time when running in Azure.
134
133
135
134
There are two ways to view a stream of the log data being generated by your function executions.
136
135
137
-
***Built-in log streaming**: the App Service platform lets you view a stream of your application log files. This stream is equivalent to the output seen when you debug your functions during [local development](functions-develop-local.md) and when you use the **Test** tab in the portal. All log-based information is displayed. For more information, see [Stream logs](../app-service/troubleshoot-diagnostic-logs.md#stream-logs). This streaming method supports only a single instance, and can't be used with an app running on Linux in a Consumption plan.
136
+
-**Built-in log streaming**: the App Service platform lets you view a stream of your application log files. This stream is equivalent to the output seen when you debug your functions during [local development](functions-develop-local.md) and when you use the **Test** tab in the portal. All log-based information is displayed. For more information, see [Stream logs](../app-service/troubleshoot-diagnostic-logs.md#stream-logs). This streaming method supports only a single instance, and can't be used with an app running on Linux in a Consumption plan.
138
137
139
-
***Live Metrics Stream**: when your function app is [connected to Application Insights](configure-monitoring.md#enable-application-insights-integration), you can view log data and other metrics in near real time in the Azure portal using [Live Metrics Stream](/azure/azure-monitor/app/live-stream). Use this method when monitoring functions running on multiple-instances or on Linux in a Consumption plan. This method uses [sampled data](configure-monitoring.md#configure-sampling).
138
+
-**Live Metrics Stream**: when your function app is [connected to Application Insights](configure-monitoring.md#enable-application-insights-integration), you can view log data and other metrics in near real time in the Azure portal using [Live Metrics Stream](/azure/azure-monitor/app/live-stream). Use this method when monitoring functions running on multiple-instances or on Linux in a Consumption plan. This method uses [sampled data](configure-monitoring.md#configure-sampling).
140
139
141
140
Log streams can be viewed both in the portal and in most local development environments. To learn how to enable log streams, see [Enable streaming execution logs in Azure Functions](streaming-logs.md).
142
141
143
142
## Diagnostic logs
144
143
145
144
Application Insights lets you export telemetry data to long-term storage or other analysis services.
146
145
147
-
Because Functions also integrates with Azure Monitor, you can also use diagnostic settings to send telemetry data to various destinations, including Azure Monitor logs. To learn more, see [Monitoring Azure Functions with Azure Monitor Logs](functions-monitor-log-analytics.md).
146
+
Because Functions also integrates with Azure Monitor, you can also use diagnostic settings to send telemetry data to various destinations, including Azure Monitor logs. To learn more, see [Monitor Azure Functions](functions-monitor-log-analytics.md).
148
147
149
148
## Scale controller logs
150
149
151
-
The [Azure Functions scale controller](./event-driven-scaling.md#runtime-scaling) monitors instances of the Azure Functions host on which your app runs. This controller makes decisions about when to add or remove instances based on current performance. You can have the scale controller emit logs to Application Insights to better understand the decisions the scale controller is making for your function app. You can also store the generated logs in Blob storage for analysis by another service.
150
+
The [Azure Functions scale controller](./event-driven-scaling.md#runtime-scaling) monitors instances of the Azure Functions host on which your app runs. This controller makes decisions about when to add or remove instances based on current performance. You can have the scale controller emit logs to Application Insights to better understand the decisions the scale controller is making for your function app. You can also store the generated logs in Blob storage for analysis by another service.
152
151
153
152
To enable this feature, you add an application setting named `SCALE_CONTROLLER_LOGGING_ENABLED` to your function app settings. To learn how, see [Configure scale controller logs](configure-monitoring.md#configure-scale-controller-logs).
154
153
155
154
## Azure Monitor metrics
156
155
157
-
In addition to log-based telemetry data collected by Application Insights, you can also get data about how the function app is running from [Azure Monitor Metrics](/azure/azure-monitor/essentials/data-platform-metrics). To learn more, see [Monitoring with Azure Monitor](monitor-functions.md).
156
+
In addition to log-based telemetry data collected by Application Insights, you can also get data about how the function app is running from [Azure Monitor Metrics](/azure/azure-monitor/essentials/data-platform-metrics). To learn more, see [Monitor Azure Functions](monitor-functions.md).
158
157
159
158
## Report issues
160
159
@@ -164,5 +163,5 @@ To report an issue with Application Insights integration in Functions, or to mak
164
163
165
164
For more information, see the following resources:
0 commit comments