🟢 Azure Monitor
✅ What is it?
- A unified monitoring service in Azure for metrics, logs, and alerts.
- Collects data from apps, VMs, containers, databases, storage, networking, etc.
- Acts as the foundation for observability in Azure.
👉 Think of Azure Monitor as the big umbrella → it collects & stores monitoring data.
✅ Key Components
- Metrics → numerical time-series data (CPU %, memory, requests/sec).
- Logs → detailed event & diagnostic data (stored in Log Analytics).
- Alerts → notifications when thresholds are crossed.
- Dashboards → visualize metrics/logs.
- Workbooks → custom interactive reports.
🟢 Azure Application Insights (App Insights)
✅ What is it?
- An APM (Application Performance Monitoring) service under Azure Monitor.
- Monitors application performance, failures, requests, dependencies, and usage.
- Works with .NET, Java, Node.js, Python, and front-end JS apps.
👉 Think of App Insights as the “inside view” of your app, while Azure Monitor is the “outside view” of the entire infrastructure.
✅ Key Features
- Request tracking → HTTP/API calls, response times.
- Dependency tracking → DB calls, external services, APIs.
- Exception logging → auto-capture unhandled errors.
- Distributed Tracing → track requests across microservices.
- Live Metrics Stream → see real-time requests & failures.
- Smart Detection → automatic anomaly alerts.
🟢 How They Work Together
- Azure Monitor → collects logs & metrics from all Azure resources.
- Application Insights → specializes in application-level monitoring.
- App Insights sends data to Azure Monitor Logs (Log Analytics workspace).
🟢 Example: Enable App Insights in .NET
// Program.cs in .NET 6/7+
var builder = WebApplication.CreateBuilder(args);
// Add Application Insights telemetry
builder.Services.AddApplicationInsightsTelemetry();
var app = builder.Build();
app.MapGet("/", () => "Hello Azure Monitor!");
app.Run();
👉 This automatically tracks requests, dependencies, and exceptions.
🟢 Security & Best Practices
- Don’t log sensitive data (PII, secrets).
- Use Sampling → reduce telemetry cost by only sending a % of requests.
- Use Custom Events/Properties for business metrics.
- Enable Alerts → e.g., notify when request failure > 5%.
🟢 Common Interview Questions
Azure Monitor
- What is Azure Monitor?
- Difference between Metrics and Logs?
- How do you set up alerts?
- What is Log Analytics?
Application Insights
- What does App Insights monitor?
- Difference between App Insights and Log Analytics?
- How do you enable App Insights in .NET?
- What is Distributed Tracing?
- What is Sampling in App Insights?
- How do you track custom events in App Insights?
🟢 Pros & Cons
Application Insights
✅ Easy integration with apps.
✅ Powerful APM features (tracing, requests, failures).
✅ Live metrics & smart detection.
❌ Cost grows with high telemetry.
❌ Overhead if not sampled properly.
Azure Monitor
✅ Single pane for infra + app monitoring.
✅ Flexible queries (KQL in Log Analytics).
✅ Alerts, dashboards, automation.
❌ Querying requires KQL learning curve.
✅ Quick Recap
- Azure Monitor = big umbrella (infra + app monitoring).
- App Insights = application-level monitoring (APM).
- Monitor → Metrics, Logs, Alerts.
- App Insights → Requests, Dependencies, Exceptions, Tracing.
- Always mention → integration, sampling, alerts, dashboards in interviews.
Comments
Post a Comment