chart
Aggregate events for a chart, with an `over` axis field and `by` split fields.
Use chart to aggregate your events for a chart. Choose an over field for the axis and by fields to split the series.
Syntax
... | chart <agg> [as <name>] [, <agg> ...] [over <field> ...] [by <field> ...]| Part | Description |
|---|---|
agg | Any stats aggregation, such as count, dc(f), avg(f). |
over | The axis field (the x-axis of a bar or column chart). |
by | Split fields (one series per value). |
You can start a query with chart and no pipe.
How it works
chartaggregates exactly likestats. Theoverfields come first, then thebyfields, and together they form the grouping.- The result is one row per combination of
overandbyvalues (long format). The chart view draws theoverfield on the axis and one series perbyvalue. - Rows are ordered by the first aggregation, descending, like
stats.
Examples
HTTP status codes per method:
class_uid=4002 | chart count over http_request.http_method by http_response.codeFailed logons per host, split by logon type:
class_uid=3002 status_id=2 | chart count over device.hostname by logon_typeBytes sent per destination port:
class_uid=4001 | chart sum(traffic.bytes_out) as sent_bytes over dst_endpoint.portCloudTrail calls per service, split by region:
metadata.log_source=aws_cloudtrail | chart count over api.service.name by cloud.regionWithout over, chart ... by behaves like stats ... by:
class_uid=1007 | chart dc(process.name) as distinct_processes by device.hostnameNotes
- For an aggregation per time bucket, use timechart.