boxplot

Calculates the minimum, maximum, and quartile values needed to draw a box plot. You can optionally split the statistics by group.

Command properties

ItemDescription
Command typeProcessing query
Required permissionNone
License usageN/A
Parallel executionNot supported
Distributed executionRuns on Control Node (reducer)

Syntax

boxplot EXPR [by FIELD, ...]

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 the by clause, box plot statistics are calculated independently for records that share the same group field values.

Output fields

FieldTypeDescription
minnumericMinimum value per group
iqr1numericFirst quartile (Q1) per group: the value at the 25th percentile of all data
iqr2numericSecond quartile (Q2, median) per group: the value at the 50th percentile
iqr3numericThird quartile (Q3) per group: the value at the 75th percentile of all data
maxnumericMaximum value per group
countintegerRecord count per group

Error codes

Parse errors
Error codeMessageDescription
20000Incomplete expressionThe syntax is incomplete, for example the by clause ends with a comma.
20001No expression value enteredNo 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

  1. Computing summary statistics for all CPU usage values

    json "[{'usage': 10}, {'usage': 25}, {'usage': 50}, {'usage': 75}, {'usage': 90}]"
    | boxplot usage
    

    Calculates the minimum, maximum, and quartile values for the usage field.

  2. Computing response time statistics by group

    table duration=1h web_logs
    | boxplot elapsed by method
    

    Calculates the minimum, maximum, and quartile values of the elapsed field for each group sharing the same method field value.

  3. Computing daily statistics

    table duration=7d web_logs
    | eval day = string(_time, "yyyy-MM-dd")
    | boxplot bytes by day
    

    Groups records by the day field and calculates box plot statistics for the bytes field.