Revert 8059d0399520322abd56f2f1adaf14029a60529c...18cbcfe4900f67e2684296c73bf974b1e4a1f15e on 14. Using Application Insights in eShopOnContainers

David Sanz 2017-10-24 18:37:21 +02:00
parent 18cbcfe490
commit 0c00b81907

@ -1,45 +1 @@
# Configure Application Insights for eShopLegacy applications
The MVC and WebForms modernized applications have installed the Application Insights Nuget packages to produce metrics and send it to an Azure Application Insights service. The only thing we need to configure is the Instrument Key of the Azure Application Insights where we want to receive the data.
We can find in the 'docker-compose.override.yml' file the variable to set:
```
- AppInsightsInstrumentationKey=${APP_INSIGHTS_INSTRUMENTATION_KEY}
```
As for the rest of variables it needs to be set in different ways depending on the environment (VM, Serfice Fabric or Kubernetes).
## Create Azure Application Insights
Open the Azure portal, click new, and search for Application Insights. In the creation form select Application Type `Asp.NET web application`.
![Create Insights](img/appinsights/create-insights.png)
Once created the App Insights, go to the Configuration and enable 'Multi-role application map'.
![Enable multi role map](./img/appinsights/settings-insights.png)
Finally retrieve the Instrumentation Key from you Application Insights service and set it in your application as the value for the `AppInsightsInstrumentationKey` variable.
## Different kind of metrics in Azure Application Insights
Once the instrumentation key is set in the settings of the application and the Azure Applications Insights is created in our Azure portal, everything is ready to start receiving the metrics. Go to the Portal and select the Application Insights service bound to your application. There you can click on 'Search' in order to see all the metrics. You can select multiple filters to customize the list results.
![Search list](img/appinsights/search-list.png)
You can see in the Search list, among other metrics, the log traces of the applications under the `TRACE` type. The traces have been added to the metrics by installing in the MVC and WebForms applications the optional Nuget package Microsoft.ApplicationInsights.TraceListener with its corresponding configuration.
![Trace request](img/appinsights/trace-logs-insights.png)
Another metric, this one automatically retrieved by default, are the web requests under the `REQUEST` type:
![Post request](./img/appinsights/post-request-insights.png)
For the requests as extra information you can see the field 'Cloud role name'. In this field we store the name of the service, allowing us to filter all the requests by the name of the service we want to. 'Cloud role name' parameter has been configured in the applications with the class `MyTelemetryInitializer`, a custom telemetry initializer which implements `ITelemetryInitializer`. Otherwise the parameter will not appear. You can review this initializer to add your own values to the Cloud role name.
In order to get some extra information from the metrics when the services are in a Service Fabric cluster, we have installed the optional Nuget package Microsoft.ApplicationInsights.ServiceFabric. Here we obtain information about the node where the container is:
![Get request](img/appinsights/request-metrics.png)
In this case as you can notice that 'Clour role name' parameter does not appear here. By clicking the `...` at the end of the property list, we can see again the configured 'Clour role name' parameter with the name of the service, in this case the eShopModernizedWebForms:
![Detailed request metrics](img/appinsights/request-details-metrics.png)
TBD