1.7 KiB
1.7 KiB
| title | description | aliases | menu | weight | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| group() function | The group() function groups records based on their values for specific columns. |
|
|
401 |
The group() function groups records based on their values for specific columns.
It produces tables with new group keys based on provided properties.
Function type: Transformation
group(columns: ["host", "_measurement"], mode:"by")
// OR
group(columns: ["_time"], mode:"except")
// OR
group()
Parameters
columns
List of columns to use in the grouping operation.
Defaults to [].
Data type: Array of strings
mode
The mode used to group columns.
Data type: String
The following options are available:
- by
- except
Defaults to "by".
by
Groups records by columns defined in the columns parameter.
except
Groups records by all columns except those defined in the columns parameter.
Examples
Group by host and measurement
from(bucket: "telegraf/autogen")
|> range(start: -30m)
|> group(columns: ["host", "_measurement"])
Group by everything except time
from(bucket: "telegraf/autogen")
|> range(start: -30m)
|> group(columns: ["_time"], mode: "except")
Remove all grouping
from(bucket: "telegraf/autogen")
|> range(start: -30m)
|> group()
Related InfluxQL functions and statements:
GROUP BY (similar but different)