Skip to content

Commit f4fd076

Browse files
Merge pull request #89834 from lostmygithubaccount/master
update webservice endpoint monitoring article
2 parents a0a5a65 + b0ee9c0 commit f4fd076

File tree

3 files changed

+62
-48
lines changed

3 files changed

+62
-48
lines changed
Lines changed: 62 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
---
2-
title: Set up Azure Application Insights to monitor ML models
2+
title: Monitor and collect data from Machine Learning web service endpoints
33
titleSuffix: Azure Machine Learning
44
description: Monitor web services deployed with Azure Machine Learning using Azure Application Insights
55
services: machine-learning
66
ms.service: machine-learning
77
ms.subservice: core
88
ms.topic: conceptual
99
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
1313
ms.custom: seoapril2019
1414
---
15-
# Monitor your Azure Machine Learning models with Application Insights
15+
# Monitor and collect data from ML web service endpoints
1616

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:
1818
* Request rates, response times, and failure rates.
1919
* Dependency rates, response times, and failure rates.
2020
* Exceptions.
2121

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).
2323

2424

2525
## Prerequisites
@@ -29,8 +29,43 @@ In this article, you learn how to set up Azure Application Insights for Azure Ma
2929
* 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).
3030
* 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.
3131

32+
## Web service input and response data
3233

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+
[![List of services on the Deployments tab](media/how-to-enable-app-insights/Deployments.PNG)](./media/how-to-enable-app-insights/Deployments.PNG#lightbox)
45+
46+
3. Select **Edit**.
47+
48+
[![Edit button](media/how-to-enable-app-insights/Edit.PNG)](./media/how-to-enable-app-insights/Edit.PNG#lightbox)
49+
50+
4. In **Advanced Settings**, select the **Enable AppInsights diagnostics** check box.
51+
52+
[![Selected check box for enabling diagnostics](media/how-to-enable-app-insights/AdvancedSettings.png)](./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+
[![Use the edit button](media/how-to-enable-app-insights/Edit.PNG)](./media/how-to-enable-app-insights/Edit.PNG#lightbox)
61+
62+
1. In **Advanced Settings**, clear the **Enable AppInsights diagnostics** check box.
63+
64+
[![Cleared check box for enabling diagnostics](media/how-to-enable-app-insights/uncheck.png)](./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
3469

3570
### Update a deployed service
3671
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
3974
from azureml.core.webservice import Webservice
4075
aks_service= Webservice(ws, "my-service-name")
4176
```
42-
2. Update your service and enable Application Insights.
77+
2. Update your service and enable Azure Application Insights.
4378

4479
```python
4580
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
6499

65100
### Disable tracking in Python
66101

67-
To disable Application Insights, use the following code:
102+
To disable Azure Application Insights, use the following code:
68103

69104
```python
70105
## replace <service_name> with the name of the web service
71106
<service_name>.update(enable_app_insights=False)
72107
```
73108

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-
[![List of services on the Deployments tab](media/how-to-enable-app-insights/Deployments.PNG)](./media/how-to-enable-app-insights/Deployments.PNG#lightbox)
83-
84-
3. Select **Edit**.
85-
86-
[![Edit button](media/how-to-enable-app-insights/Edit.PNG)](./media/how-to-enable-app-insights/Edit.PNG#lightbox)
87-
88-
4. In **Advanced Settings**, select the **Enable AppInsights diagnostics** check box.
89-
90-
[![Selected check box for enabling diagnostics](media/how-to-enable-app-insights/AdvancedSettings.png)](./media/how-to-enable-app-insights/AdvancedSettings.png#lightbox)
91-
92-
1. Select **Update** at the bottom of the screen to apply the changes.
93-
94-
### Disable
95-
1. In the [Azure portal](https://portal.azure.com), open your workspace.
96-
1. Select **Deployments**, select the service, and select **Edit**.
97-
98-
[![Use the edit button](media/how-to-enable-app-insights/Edit.PNG)](./media/how-to-enable-app-insights/Edit.PNG#lightbox)
99-
100-
1. In **Advanced Settings**, clear the **Enable AppInsights diagnostics** check box.
101-
102-
[![Cleared check box for enabling diagnostics](media/how-to-enable-app-insights/uncheck.png)](./media/how-to-enable-app-insights/uncheck.png#lightbox)
103-
104-
1. Select **Update** at the bottom of the screen to apply the changes.
105-
106-
107109
## Evaluate data
108-
Your service's data is stored in your Application Insights account, within the same resource group as Azure Machine Learning.
110+
Your service's data is stored in your Azure Application Insights account, within the same resource group as Azure Machine Learning.
109111
To view it:
110-
1. Go to your Machine Learning service workspace in the [Azure portal](https://portal.azure.com) and click on Application Insights link.
112+
1. Go to your Machine Learning service workspace in the [Azure portal](https://portal.azure.com). Click on Azure Application Insights link.
111113

112114
[![AppInsightsLoc](media/how-to-enable-app-insights/AppInsightsLoc.png)](./media/how-to-enable-app-insights/AppInsightsLoc.png#lightbox)
113115

114116
1. Select the **Overview** tab to see a basic set of metrics for your service.
115117

116118
[![Overview](media/how-to-enable-app-insights/overview.png)](./media/how-to-enable-app-insights/overview.png#lightbox)
117119

120+
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.
122+
123+
[![Model data](media/how-to-enable-app-insights/model-data-trace.png)](./media/how-to-enable-app-insights/model-data-trace.png#lightbox)
124+
125+
118126
3. To look into your custom traces, select **Analytics**.
119127
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.
120128

121129
[![Custom traces](media/how-to-enable-app-insights/logs.png)](./media/how-to-enable-app-insights/logs.png#lightbox)
122130

123-
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.
136+
137+
[![Continuous Export](media/how-to-enable-app-insights/continuous-export-setup.png)](./media/how-to-enable-app-insights/continuous-export-setup.png)
124138

125139

126140
## Example notebook
@@ -130,6 +144,6 @@ The [enable-app-insights-in-production-service.ipynb](https://github.com/Azure/M
130144
[!INCLUDE [aml-clone-in-azure-notebook](../../../includes/aml-clone-for-examples.md)]
131145

132146
## Next steps
133-
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).
134147

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.
48.2 KB
Loading
324 KB
Loading

0 commit comments

Comments
 (0)