Azure Application Insights: Monitoring, KQL Queries and Observability in Production
Source: Dev.to
At 2am on a Tuesday, an IP address change in Microsoft It was Azure Application Insights that found it. The Application Map showed 100% failure rate on the That incident shaped how I think about observability This post covers everything I learned using App Insights The first thing that surprises most engineers is how Every HTTP request your API receives - the URL, method, Every dependency call your app makes outbound - SQL Every unhandled exception with the full stack trace, Every log message you write with ILogger - Information, Performance counters including CPU usage, memory Three steps and you are done. Install the NuGet package: Add one line in Program.cs: Add the connection string to appsettings.json or That is it. Every ILogger call in your code now goes For custom events and metrics - tracking business-level KQL (Kusto Query Language) is what makes App Insights The basic structure is always the same: Once you understand five queries you can write almost All failed requests in the last hour: requests This was my first query every morning and after every Slowest API endpoints today: requests This identified performance regressions immediately All exceptions with full detail: exceptions The innermostMessage field is the one you want - Dependency failures - what external calls failed: dependencies This was how I found the Microsoft IP change. Error rate by hour - spot patterns: requests This chart pattern shows you whether failures are Beyond the standard queries, I built several patterns Cross-system correlation - following one record through union requests, dependencies, traces, exceptions Token refresh monitoring - tracking the 3-month customEvents Integration pipeline health - the Monday morning query requests The real power of App Insights is alerts that find Metric alerts fire when a number crosses a threshold - Log alerts run a KQL query on a schedule and fire if Smart detection requires no configuration. App Insights Live Metrics shows you what is happening with less than I had Live Metrics open on a second monitor during This practice caught one bad deployment at Blue Yonder The Application Map is the fastest way to understand When the Microsoft IP change broke our pipeline, the Every request in App Insights gets a unique Operation ID In Transaction Search, paste the Operation ID and see The practical implication for code: add a CorrelationId App Insights works with every Azure service. Logic Apps The goal is one workspace where you can query across Set up App Insights before you write business logic. Use structured logging with named parameters. Add CorrelationId to everything. Every log entry, Learn five queries well rather than memorizing dozens. Set DLQ alerts before going live. Silent message loss Enable sampling in production. A busy integration The C# ASP.NET Core API powering this blog has If you are reading this post and wondering whether Azure Application Insights gives you complete visibility Build it in from day one. Set your alerts. Learn your Originally published at TechStack Blog: https://www.techstackblog.com Follow for weekly posts on Azure integration, C#, observability, and cloud engineering.