- Query Template Links
- the Query API
- the Boards API
- the Triggers API
To convert query JSON into a sharable query URL, refer to Query Template Links documentation.
Fields on a Query Specification
All fields are optional, but a query without anycalculations values will have COUNT applied automatically.
breakdowns: a list of strings describing the columns by which to break events down into groupscalculations: a list of objects describing the calculations to return as a time series and summary table. Each calculation consists of anopand acolumn(except forCOUNTorCONCURRENCY, which need no column). If nocalculationsare provided,COUNTis applied. See below for a list of validops.filters: a list of objects describing the filters with which to restrict the considered events. Each filter consists of acolumn,op, and (sometimes)value. See below for a list of validops.filter_combination: either"AND"or"OR". If multiple filters are specified,filter_combinationdetermines how they are applied; set to"OR"to match ANY filter in the filter list. Defaults to"AND".granularity: an integer describing the time resolution of the query’s graph, in seconds. Valid values are the query’s time range /10 at maximum, and /1000 at minimum.orders: a list of objects describing the terms on which to order the query results. Each term must appear in either thebreakdownsfield or thecalculationsfield.limit: an integer describing the maximum number of query results.havings: a list of objects describing filters with which to restrict returned groups. Eachhavingconsists of acalculate_op(the same set used foropincalculations, but excludingHEATMAP), acolumn(except forCOUNT, which needs no column), an op (=,>,>=,<,<=), and avalue(currently assumed to be numeric). Eachcolumn/calculate_oppair must appear in thecalculationsfield. There can be multiplehavingsfor the samecolumn/calculate_oppair.time_range: an integer describing the time range of query in seconds, for relative-time queries. Cannot be combined with bothstart_timeandend_time(See caveat below.) Defaults to two hours.start_time: an integer describing the UNIX timestamp of the absolute start time of the query.end_time: an integer describing the UNIX timestamp of the absolute end time of the query.calculated_fields: a list of objects defining the calculated fields that are computed from your data using expressions. Each calculated field consists of aname(used to reference it in calculations, filters, or ordering) and anexpression(a formula that derives its value from existing fields).
How to Specify an Absolute Time Range
To specify an absolute time range, usestart_time and end_time (both UNIX timestamps) to describe the desired range:
start_time or end_time can also be used in combination with time_range to specify a fixed time plus a range.
Specifying values for all three fields, however, will result in an error.
The following describes “the one-hour period leading up to the absolute time 2024-05-01 00:00 UTC”:
start_time or end_time, a single time_range argument will default to an end_time of “now.”
The following describes “the last hour” relative to the time of invocation:
Examples
Top Ten Unique user_agents by Volume
This query specification calculates the top 10 (by volume, or COUNT) unique user_agents for the hour leading up to the absolute time 2024-01-01 00:00 UTC:
Query Builder Query
| VISUALIZE | WHERE | GROUP BY |
|---|---|---|
| COUNT | user_agent |
JSON
Average Content Length of Events
This query specification calculates theAVG(content_length) of events from the last hour matching kafka_partition = 3 or kafka_partition = 6:
Query Builder Query
| VISUALIZE | WHERE |
|---|---|
| AVG (content_length) | kafka_partition = 3 OR kafka_partition = 6 |
Filter Events Based on Length of Duration and Service Name
This query specification matches events withduration_ms > 500 and service.name != "fraud", then calculates a HEATMAP(match_quality) (where the graph spans the last 3 hours, drawn at 15-minute intervals):
Query Builder Query
| VISUALIZE | WHERE |
|---|---|
| HEATMAP(match_quality) | duration_ms > 500 service.name != “fraud” |
JSON
Top 100 Results for Average Duration and 99th Percentile of Event Duration Ranked by Duration and User
This query specification describes an absolute-time query which matches events withresult = 200, then calculates the AVG(duration_ms) and P99(duration_ms) broken down into unique (user_id, build_id) pairs. It then returns the first 100 results, ordered first by P99(duration_ms) values, then user_id.
Query Builder Query
| VISUALIZE | WHERE | GROUP BY |
|---|---|---|
| AVG(duration_ms) P99(duration_ms) | result = 200 | user_id build_id |
| ORDER BY | LIMIT |
|---|---|
| P99(duration_ms) desc user_id desc | 100 |
JSON
Top 100 Results for Events with a Duration With Longer Than 10000 Milliseconds
This query specification describes a query over the last hour that matches events withresult = 200, then calculates the AVG(duration_ms) and P99(duration_ms) broken down into unique (user_id, build_id) pairs. It then returns the first 100 results that have a P99(duration_ms) > 10000, ordered first by P99(duration_ms) values, then user_id.
Query Builder Query
| VISUALIZE | WHERE | GROUP BY |
|---|---|---|
| AVG(duration_ms) P99(duration_ms) | result = 200 | user_id build_id |
| ORDER BY | LIMIT | HAVING |
|---|---|---|
| P99(duration_ms) desc user_id | 100 | P99(duration_ms) > 10000 |
JSON
Match Specific Users and Identify Experienced Errors
This query specification describes a query that filters for specific users based on their email address who are experiencing errors broken down by error code.Query Builder Query
| VISUALIZE | WHERE | GROUP BY |
|---|---|---|
| COUNT | app.user.email in foo@example.com, bar@example.com error exists | error.code |
JSON
Calculation Operators
Calculation operators are consistent between the API and the UI. The available calculation"op" values are:
COUNT(optionally expects an accompanying"column"value)CONCURRENCY(does not expect an accompanying"column"value)SUMAVGCOUNT_DISTINCTMAXMINP001P01P05P10P20P25P50P75P80P90P95P99P999HEATMAPRATE_AVGRATE_SUMRATE_MAX
Filter Operators
Filter operators are consistent between the API and the UI. The available filter"op" values are:
=!=>>=<<=starts-withdoes-not-start-withends-withdoes-not-end-withexists(does not expect an accompanying"value")does-not-exist(does not expect an accompanying"value")containsdoes-not-containin(filter"value"must be present and be an array - example)not-in(filter"value"must be present and be an array)