Azure Application Insights for Spring Boot Observability
Fast recall
Quick revision
Core answer
Knowledge of APM instrumentation in Java — specifically the agent-based auto-instrumentation approach vs. manual SDK calls.
Embedding the Application Insights SDK into application code with manual track*() calls instead of using the zero-code Java agent.
Mention distributed tracing via W3C TraceContext propagation, Log4j/SLF4J correlation ID injection, and Live Metrics for real-time monitoring.
Interview-ready guide
Interview answer
Application Insights provides distributed tracing, metrics, and log aggregation for Spring Boot services on Azure — the recommended approach is the Java agent, not the SDK, because the agent instruments the application without any code changes.
Java agent — zero-code instrumentation
- Attach the agent as a JVM argument:
-javaagent:/path/to/applicationinsights-agent.jar; in App Service, setJAVA_TOOL_OPTIONS=-javaagent:/path/applicationinsights-agent.jarin the application settings - The agent auto-instruments HTTP requests (request duration, status codes), Spring Data queries (SQL timing, query text), outbound HTTP calls, and exception logging — all without any application code changes
- Application Insights collects this telemetry and correlates it with a distributed trace ID, which means a slow API call can be traced through the Spring Boot service to the database query that caused it
Connection string configuration
- Configure
APPLICATIONINSIGHTS_CONNECTION_STRINGas an environment variable or application setting — this is the only configuration the agent needs; the connection string includes the instrumentation key and the regional endpoint
Custom telemetry with Micrometer
- The Application Insights Java agent integrates with Micrometer automatically — custom
Counter,Timer, andGaugemetrics registered with theMeterRegistryare published to Application Insights as custom metrics - Use
TelemetryClientfrom the Application Insights SDK for custom events and properties:telemetryClient.trackEvent("OrderPlaced", properties, metrics)adds domain events to the telemetry stream
Querying with Kusto (KQL)
- Application Insights stores telemetry in Log Analytics; queries use Kusto Query Language:
requests | where duration > 500 | summarize count() by bin(timestamp, 5m)finds slow requests per 5-minute window - Create dashboards and alerts directly in Application Insights from KQL queries
Azure Application Insights for Spring Boot Observability
Direct Answer
Add the Application Insights Java agent (applicationinsights-agent.jar) as a JVM argument. It auto-instruments Spring Boot, captures distributed traces, exceptions, and custom metrics without code changes, forwarding everything to Azure Monitor.
Common Mistakes & Pitfalls
Embedding the Application Insights SDK into application code with manual track*() calls instead of using the zero-code Java agent.
Check your understanding
Answer these without looking back at the article.
- How does Application Insights distributed tracing correlate logs across microservices?
- How do you configure adaptive sampling in Application Insights to control costs?
- What is the difference between Application Insights and Azure Monitor?
Related interview prep categories
1Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.