boxplot
Calculates the minimum, maximum, and quartile values needed to draw a box plot. You can optionally split the statistics by group.
Command properties
| Item | Description |
|---|---|
| Command type | Processing query |
| Required permission | None |
| License usage | N/A |
| Parallel execution | Not supported |
| Distributed execution | Runs on Control Node (reducer) |
Syntax
Target
EXPR- Expression to compute statistics on. Records where the expression result is null are ignored.
[by FIELD, ...]- Group fields. Separate multiple fields with commas (
,). When you specify thebyclause, box plot statistics are calculated independently for records that share the same group field values.
Output fields
| Field | Type | Description |
|---|---|---|
| min | numeric | Minimum value per group |
| iqr1 | numeric | First quartile (Q1) per group: the value at the 25th percentile of all data |
| iqr2 | numeric | Second quartile (Q2, median) per group: the value at the 50th percentile |
| iqr3 | numeric | Third quartile (Q3) per group: the value at the 75th percentile of all data |
| max | numeric | Maximum value per group |
| count | integer | Record count per group |
Error codes
Parse errors
| Error code | Message | Description |
|---|---|---|
| 20000 | Incomplete expression | The syntax is incomplete, for example the by clause ends with a comma. |
| 20001 | No expression value entered | No expression is specified for the statistics target. |
Runtime errors
N/A
Description
The boxplot command collects all input records, sorts them by the value of the specified expression, and calculates the minimum, maximum, and quartile values. When you use the by clause, statistics are calculated independently for records that share the same group field values.
Records where the expression result is null are excluded from the statistics. Output records include the min, iqr1, iqr2, iqr3, max, and count fields. When you specify a by clause, the group fields are also included in the output.
In a distributed environment, the final calculation runs on the Control Node.
Examples
-
Computing summary statistics for all CPU usage values
json "[{'usage': 10}, {'usage': 25}, {'usage': 50}, {'usage': 75}, {'usage': 90}]" | boxplot usageCalculates the minimum, maximum, and quartile values for the
usagefield. -
Computing response time statistics by group
table duration=1h web_logs | boxplot elapsed by methodCalculates the minimum, maximum, and quartile values of the
elapsedfield for each group sharing the samemethodfield value. -
Computing daily statistics
table duration=7d web_logs | eval day = string(_time, "yyyy-MM-dd") | boxplot bytes by dayGroups records by the
dayfield and calculates box plot statistics for thebytesfield.