Comparison
MetricvsStructured logging
Metric
you record a number over time so you can see the shape of the whole system at once without reading a single log line.
An aggregated numeric time series: counters, gauges, histograms. Metrics are cheap, bounded in volume and ideal for alerting and dashboards. They cannot tell you about one specific request, which is where logs and traces take over.
Full entry →Structured logging
you log an object with named fields instead of a sentence, so you can query on user id rather than grep for it.
Emitting logs as machine-parseable records with consistent field names. It turns logs into something queryable and aggregatable rather than something you read. The discipline is in the field names: a user id logged under four different keys is four fields that cannot be joined.
Full entry →