Log-based metrics
Turn counts and averages out of your logs, without writing an agent.
What they are #
A log-based metric counts, sums or averages values found in your logs on a fixed schedule. It gives you a metric from data you are already sending, with no agent to deploy.
Metric kinds #
- Count — how many records matched. The default, and the one to reach for first.
- Sum — the total of a numeric field across matching records.
- Average — the mean of a numeric field across matching records.
Configuration #
- Name — how the metric appears in the metrics explorer.
- Type — count, sum or average.
- Filter — which logs contribute.
- Field — the numeric attribute to aggregate, for sum and average.
- Group by — the dimensions to break the metric down by.
- Schedule — how often the metric is computed.
{
"name": "checkout.failed_orders",
"type": "count",
"filter": "service:checkout status:error @payment.declined:true",
"groupBy": ["env", "payment.provider"],
"schedule": "*/5 * * * *"
}Counting semantics #
A bucket that receives several records sums their counts; every other kind is averaged. This keeps a five-minute bucket correct whether it received one record or ten thousand.
Grouping dimensions #
Group by any attribute you already send. Grouping by an attribute with a very large number of distinct values produces a metric with a very large number of series, so choose dimensions that stay bounded.
Using them #
The metric appears in the metrics explorer alongside everything else, and can be charted, put on a dashboard and used in monitors.
Start with a count and no grouping. Once you know the shape, add one grouping dimension at a time.