Configure Application Insights to receive monitoring information from your apps
You now know how to live stream any logs to your console. Next, you will configure Application Insights for your apps. Spring Apps Service uses an in-process Java Agent for Application Insights. When you first created your service, an Application Insights resource also got created for you by default. Double check whether this Application Insights instance is properly linked to your Spring Apps Service. If it is not, re-link Application Insights. You can use the following guidance to perform this task:
Step by step guidance
-
Run the following command to allow automatic installation of the Azure CLI extension required for this lab.
az config set extension.use_dynamic_install=yes_without_prompt
-
Run the following command to check whether Application Insights is linked to your Spring Apps Service.
az spring build-service builder buildpack-binding show --name default
This should generate an output that resembles the following content:
{ "id": "/subscriptions/xxxx/resourceGroups/rg-petclinic-592faa/providers/Microsoft.AppPlatform/Spring/sa-vnet-petclinic-592faa/buildServices/default/builders/default/buildpackBindings/default", "name": "default", "properties": { "bindingType": "ApplicationInsights", "launchProperties": { "properties": { "connection-string": "InstrumentationKey=xxxx;IngestionEndpoint=https://northeurope-5.in.applicationinsights.azure.com/;LiveEndpoint=https://northeurope. livediagnostics.monitor.azure.com/", "sampling-percentage": "10" }, "secrets": null }, "provisioningState": "Succeeded" }, "resourceGroup": "rg-petclinic-592faa", "systemData": { "createdAt": "2023-06-28T07:57:36.474785+00:00", "createdBy": "xxxx", "createdByType": "User", "lastModifiedAt": "2023-06-28T07:57:36.474785+00:00", "lastModifiedBy": "xxxx", "lastModifiedByType": "User" }, "type": "Microsoft.AppPlatform/Spring/buildServices/builders/buildpackBindings" }
This output indicates that Application Insights is enabled and that your apps are sending monitoring data to Application Insights. In case you see different output, where there is no instrumentation key, you will need to reconfigure Application Insights. In that case follow the next steps.
-
To re-enable Application Insights, you will first need to retrieve the instrumentation key of your Application Insights instance.
INSTRUMENTATIONKEY=$(az monitor app-insights component show \ -g $RESOURCE_GROUP \ --query [0].connectionString \ -o tsv)
-
You can now use this instrumentation key to reconfigure Application Insights for your Spring Apps Service.
az spring build-service builder buildpack-binding set \ --name default \ --builder-name default \ --type ApplicationInsights \ --properties sampling-percentage=10 \ connection-string=$INSTRUMENTATIONKEY
-
To validate the outcome, re-run the
az spring build-service builder buildpack-binding show
command and verify that it generates the intended output.az spring build-service builder buildpack-binding show --name default