Azure Java Spring boot Example integrating with Application Insights
Additional info is available at
Azure App Service - logging and monitoring made easy
Azure App Service - monitoring application behavior (and using custom metrics)
Configure your target App Service in pom.xml
<resourceGroup>...</resourceGroup>
<appName>...</appName>
<subscriptionId>...</subscriptionId>
Set APPINSIGHTS_INSTRUMENTATIONKEY in your Azure App Service Application settings
Provide log message in your Azure App Service Application settings
Configure your Azure deployment credentials on maven settings.xml
<server>
<id>azure-auth</id>
<configuration>
<client>...</client>
<tenant>...</tenant>
<key>...</key>
<environment>AZURE</environment>
</configuration>
</server>
Configure proxy (if required) As you configure your Java project for ApplicationInsights to allow maven download dependencies you can set maven proxies in your settings.xml (e.g. in %USERPROFILE%/.m2)
<proxies>
<proxy>
<id>mgsproxy</id>
<active>true</active>
<protocol>http</protocol>
<host>xx.xx.xx.xx</host>
<port>nnnn</port>
</proxy>
</proxies>
Deploy your application and Monitor your log messages and metrics in Azure Application Insights
- Find recent log messages with specific sub-string:
traces | where timestamp > ago(1h) | where message contains 'build' | sort by timestamp desc
- Find count of recent request for each error HTTP code:
requests | where timestamp > ago(1h) | summarize count() by resultCode
- Find recent http errors:
requests | where timestamp > ago(1h) | where toint(resultCode) >=400 and toint(resultCode) != 401 | sort by timestamp desc
- Find recent 5xx errors:
requests | where timestamp > ago(1h) | where toint(resultCode) >=500 | sort by timestamp desc
- Find recent exceptions for specific app (can use cloud_RoleName as filter):
exceptions | where timestamp > ago(1h) | where cloud_RoleName == 'springapitest0003'
| sort by timestamp desc
Note: The cloud_roleName is taken from spring.application.name
in application.properties.