Configure diagnostics settings
Application Insights allows you to monitor app-specific logs. To retrieve additional telemetry, configure diagnostic settings and use Log Analytics as the log destination. You can use the following guidance to perform this task:
Step by step guidance
-
When configuring diagnostics settings, you can do so for multiple categories of logs. Each service exposes different categories. Switch back to the Git Bash shell and run the following command to list the log categories that Spring Apps Service exposes.
az monitor diagnostic-settings categories list \ --resource $SPRING_APPS_SERVICE \ -g $RESOURCE_GROUP \ --resource-type Microsoft.AppPlatform/Spring \ --query value[].name
-
To create a Log Analytics Workspace to send the logs to, run the following command.
WORKSPACE=log-$APPNAME-$UNIQUEID az monitor log-analytics workspace create \ --resource-group $RESOURCE_GROUP \ --workspace-name $WORKSPACE
-
Once the provisioning task completes, you can configure the diagnostics settings for your Spring Apps Service and associate them with the newly created workspace. To accomplish this, first create a file logs.json and save it in the same directory you are running your Azure CLI commands from.
[ { "category": "ApplicationConsole", "enabled": true }, { "category": "SystemLogs", "enabled": true }, { "category": "IngressLogs", "enabled": true }, { "category": "BuildLogs", "enabled": true }, { "category": "ContainerEventLogs", "enabled": true } ]
-
Create another file named metrics.json in the same directory.
[ { "category": "AllMetrics", "enabled": true } ]
-
Now, reference both JSON files to configure the diagnostics settings for your Spring Apps Service, which will result in its logs being sent to the Log Analytics workspace.
az monitor diagnostic-settings create \ --name asa-logs \ --resource $SPRING_APPS_SERVICE \ --resource-type Microsoft.AppPlatform/Spring \ --resource-group $RESOURCE_GROUP \ --workspace $WORKSPACE \ --logs @logs.json \ --metrics @metrics.json
This will start log collection. It might take some time before log data is accessible from the Log Analytics workspace. In the next task, you query this data.