You can't run production without seeing errors, latency and dependencies across your services.
Azure Monitor is the umbrella for observability data:
- Metrics: numeric time series collected automatically for most resources (CPU, requests, RU consumption), kept 93 days, cheap and near real-time.
- Logs: records stored in a Log Analytics workspace and queried with KQL. Platform logs only flow there once you create a diagnostic setting on each resource (or enforce them with Policy).
- Activity log: who did what at the control plane, per subscription.
Application Insights is the application performance part. It collects requests, dependencies (SQL, HTTP, Service Bus calls), exceptions, traces and custom telemetry, and draws the application map and end-to-end transaction views. Modern Application Insights resources are workspace-based: their data lands in Log Analytics tables (AppRequests, AppDependencies, AppExceptions).
Instrument code with the Azure Monitor OpenTelemetry distro: one call configures tracing, metrics and logs, using the APPLICATIONINSIGHTS_CONNECTION_STRING setting. App Service and Functions can also enable auto-instrumentation without code changes.
Cost is driven by log ingestion volume. Use sampling, drop noisy logs, choose Basic/Auxiliary log tables for high-volume low-value data, and set retention deliberately.
Example
# pip install azure-monitor-opentelemetry fastapi
# export APPLICATIONINSIGHTS_CONNECTION_STRING="InstrumentationKey=...;IngestionEndpoint=..."
import logging
from azure.monitor.opentelemetry import configure_azure_monitor
configure_azure_monitor(logger_name="orders") # traces, metrics, logs -> App Insights
from fastapi import FastAPI # import after configuring
app = FastAPI()
log = logging.getLogger("orders")
@app.get("/orders/{oid}")
def get_order(oid: str):
log.info("fetching order %s", oid) # lands in the traces table
return {"id": oid}
# Diagnostic setting (bash) so a resource's logs reach the workspace:
# az monitor diagnostic-settings create -n to-law --resource <id> \
# --workspace <workspace id> --logs '[{"categoryGroup":"allLogs","enabled":true}]'Remember
- Metrics are automatic; resource logs need diagnostic settings
- Logs live in Log Analytics and are queried with KQL
- Application Insights = requests, dependencies, exceptions, traces
- Use the OpenTelemetry distro; control cost via sampling and retention
Watch out for
- Assuming resource logs are collected by default: without a diagnostic setting they are not stored anywhere.