Skip to content

Azure Java Spring boot Example integrating with Application Insights

Notifications You must be signed in to change notification settings

romicgd/AzureAIJavaSpringBoot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java Spring Boot Example integrating with Azure Application Insights

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)

Setup

Configure your target App Service in pom.xml

<resourceGroup>...</resourceGroup>
<appName>...</appName>
<subscriptionId>...</subscriptionId>

Set APPINSIGHTS_INSTRUMENTATIONKEY in your Azure App Service Application settings APPINSIGHTS_INSTRUMENTATIONKEY

Provide log message in your Azure App Service Application settings LogMessage

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

QueryLogs

CustomMetricsQuery

CustomMetricsGraphs

Query Examples

  1. Find recent log messages with specific sub-string:
traces | where timestamp > ago(1h) | where message contains 'build' | sort by timestamp desc
  1. Find count of recent request for each error HTTP code:
requests | where timestamp > ago(1h) | summarize count() by resultCode
  1. Find recent http errors:
requests | where timestamp > ago(1h) | where toint(resultCode) >=400 and toint(resultCode) != 401 | sort by timestamp desc
  1. Find recent 5xx errors:
requests | where timestamp > ago(1h) | where toint(resultCode) >=500 | sort by timestamp desc 
  1. 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.

About

Azure Java Spring boot Example integrating with Application Insights

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages