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
title: Set up Azure Application Insights to monitor ML models
2
+
title: Monitor and collect data from Machine Learning web service endpoints
3
3
titleSuffix: Azure Machine Learning
4
4
description: Monitor web services deployed with Azure Machine Learning using Azure Application Insights
5
5
services: machine-learning
6
6
ms.service: machine-learning
7
7
ms.subservice: core
8
8
ms.topic: conceptual
9
9
ms.reviewer: jmartens
10
-
ms.author: marthalc
11
-
author: marthalc
12
-
ms.date: 07/12/2019
10
+
ms.author: copeters
11
+
author: lostmygithubaccount
12
+
ms.date: 09/25/2019
13
13
ms.custom: seoapril2019
14
14
---
15
-
# Monitor your Azure Machine Learning models with Application Insights
15
+
# Monitor and collect data from ML web service endpoints
16
16
17
-
In this article, you learn how to set up Azure Application Insights for Azure Machine Learning. Application Insights gives you the opportunity to monitor:
17
+
In this article, you learn how to collect data from and monitor models deployed to web service endpoints in Azure Kubernetes Service (AKS) or Azure Container Instances (ACI) by enabling Azure Application Insights. In addition to collecting an endpoint's input data and response, you can monitor:
18
18
* Request rates, response times, and failure rates.
19
19
* Dependency rates, response times, and failure rates.
20
20
* Exceptions.
21
21
22
-
[Learn more about Application Insights](../../azure-monitor/app/app-insights-overview.md).
22
+
[Learn more about Azure Application Insights](../../azure-monitor/app/app-insights-overview.md).
23
23
24
24
25
25
## Prerequisites
@@ -29,8 +29,43 @@ In this article, you learn how to set up Azure Application Insights for Azure Ma
29
29
* An Azure Machine Learning workspace, a local directory that contains your scripts, and the Azure Machine Learning SDK for Python installed. To learn how to get these prerequisites, see [How to configure a development environment](how-to-configure-environment.md).
30
30
* A trained machine learning model to be deployed to Azure Kubernetes Service (AKS) or Azure Container Instance (ACI). If you don't have one, see the [Train image classification model](tutorial-train-models-with-aml.md) tutorial.
31
31
32
+
## Web service input and response data
32
33
33
-
## Use SDK to configure
34
+
The input and response to the service - corresponding to the inputs to the ML model and its prediction - are logged to the Azure Application Insights traces under the message `"model_data_collection"`. You can query Azure Application Insights directly to access this data, or set up a [continuous export](https://docs.microsoft.com/azure/azure-monitor/app/export-telemetry) to a storage account for longer retention or further processing. Model data can then be used in the Azure ML service to setup labeling, retraining, explainability, data analysis, or other use.
35
+
36
+
## Use the Azure portal to configure
37
+
38
+
You can enable and disable Azure Application Insights in the Azure portal.
39
+
40
+
1. In the [Azure portal](https://portal.azure.com), open your workspace.
41
+
42
+
1. On the **Deployments** tab, select the service where you want to enable Azure Application Insights.
43
+
44
+
[](./media/how-to-enable-app-insights/Deployments.PNG#lightbox)
4. In **Advanced Settings**, select the **Enable AppInsights diagnostics** check box.
51
+
52
+
[](./media/how-to-enable-app-insights/AdvancedSettings.png#lightbox)
53
+
54
+
1. Select **Update** at the bottom of the screen to apply the changes.
55
+
56
+
### Disable
57
+
1. In the [Azure portal](https://portal.azure.com), open your workspace.
58
+
1. Select **Deployments**, select the service, and then select **Edit**.
59
+
60
+
[](./media/how-to-enable-app-insights/Edit.PNG#lightbox)
61
+
62
+
1. In **Advanced Settings**, clear the **Enable AppInsights diagnostics** check box.
63
+
64
+
[](./media/how-to-enable-app-insights/uncheck.png#lightbox)
65
+
66
+
1. Select **Update** at the bottom of the screen to apply the changes.
67
+
68
+
## Use Python SDK to configure
34
69
35
70
### Update a deployed service
36
71
1. Identify the service in your workspace. The value for `ws` is the name of your workspace.
@@ -39,7 +74,7 @@ In this article, you learn how to set up Azure Application Insights for Azure Ma
39
74
from azureml.core.webservice import Webservice
40
75
aks_service= Webservice(ws, "my-service-name")
41
76
```
42
-
2. Update your service and enable Application Insights.
77
+
2. Update your service and enable Azure Application Insights.
43
78
44
79
```python
45
80
aks_service.update(enable_app_insights=True)
@@ -64,63 +99,42 @@ If you want to log custom traces, follow the standard deployment process for AKS
64
99
65
100
### Disable tracking in Python
66
101
67
-
To disable Application Insights, use the following code:
102
+
To disable Azure Application Insights, use the following code:
68
103
69
104
```python
70
105
## replace <service_name> with the name of the web service
71
106
<service_name>.update(enable_app_insights=False)
72
107
```
73
108
74
-
## Use portal to configure
75
-
76
-
You can enable and disable Application Insights in the Azure portal.
77
-
78
-
1. In the [Azure portal](https://portal.azure.com), open your workspace.
79
-
80
-
1. On the **Deployments** tab, select the service where you want to enable Application Insights.
81
-
82
-
[](./media/how-to-enable-app-insights/Deployments.PNG#lightbox)
1. To look into your web service input and response payloads, select **Analytics**
121
+
1. In the schema section, select **Traces** and filter down traces with the message `"model_data_collection"`. In the custom dimensions, you can see the inputs, predictions, and other relevant details.
3. To look into your custom traces, select **Analytics**.
119
127
4. In the schema section, select **Traces**. Then select **Run** to run your query. Data should appear in a table format and should map to your custom calls in your scoring file.
To learn more about how to use Application Insights, see [What is Application Insights?](../../azure-monitor/app/app-insights-overview.md).
131
+
To learn more about how to use Azure Application Insights, see [What is Application Insights?](../../azure-monitor/app/app-insights-overview.md).
132
+
133
+
## Export data for further processing and longer retention
134
+
135
+
You can use Azure Application Insights' [continuous export](https://docs.microsoft.com/azure/azure-monitor/app/export-telemetry) to send messages to a supported storage account, where a longer retention can be set. The `"model_data_collection"` messages are stored in JSON format and can be easily parsed to extract model data. Azure Data Factory, Azure ML Pipelines, or other data processing tools can be used to transform the data as needed. When you have transformed the data, you can then register it with the Azure Machine Learning service workspace as a dataset.
You can also collect data on your models in production. Read the article [Collect data for models in production](how-to-enable-data-collection.md).
134
147
135
-
Also read [Azure Monitor for containers](https://docs.microsoft.com/azure/monitoring/monitoring-container-insights-overview?toc=%2fazure%2fmonitoring%2ftoc.json).
148
+
* See [how to deploy a model to an Azure Kubernetes Service cluster](https://docs.microsoft.com/azure/machine-learning/service/how-to-deploy-azure-kubernetes-service) or [how to deploy a model to Azure Container Instances](https://docs.microsoft.com/azure/machine-learning/service/how-to-deploy-azure-container-instance) to deploy your models to web service endpoints, and enable Azure Application Insights to leverage data collection and endpoint monitoring.
149
+
* See [MLOps: Manage, deploy, and monitor models with Azure Machine Learning](https://docs.microsoft.com/azure/machine-learning/service/concept-model-management-and-deployment) to learn more about leveraging data collected from models in production. Such data can help to continually improve your machine learning process.
0 commit comments