How do you derive metrics from logs, and when should you?
IntermediateProductionLog Pipelines
Answer
When you cannot change the app (legacy, third party) or need a quick metric from existing logs. Loki recording rules:
- record: nginx:requests_5xx:rate5m
expr: sum by (cluster, app) (rate({app="nginx"} | json | status >= 500 [5m]))
Or count in the pipeline (Vector log_to_metric, OTel count connector) before storage. Native app metrics are still preferred: cheaper, more reliable.
More on Log Pipelines
What does a production log pipeline look like end to end?BeginnerWhy structured (JSON) logging, and what fields should every log line have?BeginnerFluent Bit, Vector, Grafana Alloy or the OpenTelemetry Collector: how do you choose a log agent?IntermediateWhy add an aggregation tier instead of sending directly from agents to the backend?IntermediateHow do you design log retention tiers?IntermediateHow do you scrub PII from logs in the pipeline?Intermediate