文档文档

使用 Flux 在 InfluxDB 中对数据进行分组

使用 Flux,您可以按查询数据集中的任何列对数据进行分组。“分组”将数据分区到表中,其中每行对于指定的列共享一个通用值。本指南将引导您完成在 Flux 中对数据进行分组的过程,并提供有关数据在此过程中如何成形的示例。

如果您刚开始使用 Flux 查询,请查看以下内容

  • Flux 入门,以获得 Flux 和 Flux 查询各部分的概念概述。
  • 执行查询,以发现运行查询的各种方法。

分组键

每个表都有一个分组键——一个列列表,表中每行的这些列都具有相同的值。

分组键示例
[_start, _stop, _field, _measurement, host]

在 Flux 中对数据进行分组本质上是定义输出表的分组键。了解修改分组键如何塑造输出数据是成功分组并将数据转换为所需输出的关键。

group() 函数

Flux 的 group() 函数定义了输出表的分组键,即基于特定列的值对记录进行分组。

group() 示例
dataStream
    |> group(columns: ["cpu", "host"])
生成的分组键
[cpu, host]

group() 函数具有以下参数

columns

要包含或排除在分组操作中的列列表(取决于模式)。

mode

用于定义分组和生成的分组键的方法。可能的值包括 byexcept

分组操作示例

为了说明分组的工作原理,定义一个 dataSet 变量,该变量从 example-bucket 存储桶查询系统 CPU 使用率。筛选 cpu 标签,使其仅返回每个编号 CPU 核心的结果。

数据集

所有编号 CPU 核心的系统操作使用的 CPU。它使用正则表达式来仅筛选编号的核心。

dataSet = from(bucket: "example-bucket")
    |> range(start: -2m)
    |> filter(fn: (r) => r._field == "usage_system" and r.cpu =~ /cpu[0-9*]/)
    |> drop(columns: ["host"])

此示例从返回的数据中删除 host 列,因为 CPU 数据仅针对单个主机进行跟踪,并且它简化了输出表。如果监控多个主机,请勿删除 host 列。

Table: keys: [_start, _stop, _field, _measurement, cpu]
                   _start:time                      _stop:time           _field:string     _measurement:string              cpu:string                      _time:time                  _value:float
------------------------------  ------------------------------  ----------------------  ----------------------  ----------------------  ------------------------------  ----------------------------
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu0  2018-11-05T21:34:00.000000000Z             7.892107892107892
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu0  2018-11-05T21:34:10.000000000Z                           7.2
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu0  2018-11-05T21:34:20.000000000Z                           7.4
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu0  2018-11-05T21:34:30.000000000Z                           5.5
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu0  2018-11-05T21:34:40.000000000Z                           7.4
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu0  2018-11-05T21:34:50.000000000Z                           7.5
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu0  2018-11-05T21:35:00.000000000Z                          10.3
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu0  2018-11-05T21:35:10.000000000Z                           9.2
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu0  2018-11-05T21:35:20.000000000Z                           8.4
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu0  2018-11-05T21:35:30.000000000Z                           8.5
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu0  2018-11-05T21:35:40.000000000Z                           8.6
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu0  2018-11-05T21:35:50.000000000Z                          10.2
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu0  2018-11-05T21:36:00.000000000Z                          10.6

Table: keys: [_start, _stop, _field, _measurement, cpu]
                   _start:time                      _stop:time           _field:string     _measurement:string              cpu:string                      _time:time                  _value:float
------------------------------  ------------------------------  ----------------------  ----------------------  ----------------------  ------------------------------  ----------------------------
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu1  2018-11-05T21:34:00.000000000Z            0.7992007992007992
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu1  2018-11-05T21:34:10.000000000Z                           0.7
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu1  2018-11-05T21:34:20.000000000Z                           0.7
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu1  2018-11-05T21:34:30.000000000Z                           0.4
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu1  2018-11-05T21:34:40.000000000Z                           0.7
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu1  2018-11-05T21:34:50.000000000Z                           0.7
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu1  2018-11-05T21:35:00.000000000Z                           1.4
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu1  2018-11-05T21:35:10.000000000Z                           1.2
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu1  2018-11-05T21:35:20.000000000Z                           0.8
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu1  2018-11-05T21:35:30.000000000Z            0.8991008991008991
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu1  2018-11-05T21:35:40.000000000Z            0.8008008008008008
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu1  2018-11-05T21:35:50.000000000Z             0.999000999000999
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu1  2018-11-05T21:36:00.000000000Z            1.1022044088176353

Table: keys: [_start, _stop, _field, _measurement, cpu]
                   _start:time                      _stop:time           _field:string     _measurement:string              cpu:string                      _time:time                  _value:float
------------------------------  ------------------------------  ----------------------  ----------------------  ----------------------  ------------------------------  ----------------------------
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu2  2018-11-05T21:34:00.000000000Z                           4.1
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu2  2018-11-05T21:34:10.000000000Z                           3.6
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu2  2018-11-05T21:34:20.000000000Z                           3.5
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu2  2018-11-05T21:34:30.000000000Z                           2.6
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu2  2018-11-05T21:34:40.000000000Z                           4.5
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu2  2018-11-05T21:34:50.000000000Z             4.895104895104895
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu2  2018-11-05T21:35:00.000000000Z             6.906906906906907
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu2  2018-11-05T21:35:10.000000000Z                           5.7
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu2  2018-11-05T21:35:20.000000000Z                           5.1
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu2  2018-11-05T21:35:30.000000000Z                           4.7
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu2  2018-11-05T21:35:40.000000000Z                           5.1
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu2  2018-11-05T21:35:50.000000000Z                           5.9
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu2  2018-11-05T21:36:00.000000000Z            6.4935064935064934

Table: keys: [_start, _stop, _field, _measurement, cpu]
                   _start:time                      _stop:time           _field:string     _measurement:string              cpu:string                      _time:time                  _value:float
------------------------------  ------------------------------  ----------------------  ----------------------  ----------------------  ------------------------------  ----------------------------
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu3  2018-11-05T21:34:00.000000000Z            0.5005005005005005
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu3  2018-11-05T21:34:10.000000000Z                           0.5
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu3  2018-11-05T21:34:20.000000000Z                           0.5
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu3  2018-11-05T21:34:30.000000000Z                           0.3
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu3  2018-11-05T21:34:40.000000000Z                           0.6
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu3  2018-11-05T21:34:50.000000000Z                           0.6
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu3  2018-11-05T21:35:00.000000000Z            1.3986013986013985
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu3  2018-11-05T21:35:10.000000000Z                           0.9
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu3  2018-11-05T21:35:20.000000000Z            0.5005005005005005
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu3  2018-11-05T21:35:30.000000000Z                           0.7
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu3  2018-11-05T21:35:40.000000000Z                           0.6
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu3  2018-11-05T21:35:50.000000000Z                           0.8
2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            usage_system                     cpu                    cpu3  2018-11-05T21:36:00.000000000Z                           0.9

请注意,分组键与每个表一起输出:Table: keys: <group-key>

Group example data set

按 CPU 分组

cpu 列对 dataSet 流进行分组。

dataSet
    |> group(columns: ["cpu"])

这实际上不会更改数据的结构,因为它已经在分组键中包含 cpu,因此按 cpu 分组。但是,请注意,它确实更改了分组键

按 CPU 分组输出表
Table: keys: [cpu]
            cpu:string                      _stop:time                      _time:time                  _value:float           _field:string     _measurement:string                     _start:time
----------------------  ------------------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
                  cpu0  2018-11-05T21:36:00.000000000Z  2018-11-05T21:34:00.000000000Z             7.892107892107892            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu0  2018-11-05T21:36:00.000000000Z  2018-11-05T21:34:10.000000000Z                           7.2            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu0  2018-11-05T21:36:00.000000000Z  2018-11-05T21:34:20.000000000Z                           7.4            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu0  2018-11-05T21:36:00.000000000Z  2018-11-05T21:34:30.000000000Z                           5.5            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu0  2018-11-05T21:36:00.000000000Z  2018-11-05T21:34:40.000000000Z                           7.4            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu0  2018-11-05T21:36:00.000000000Z  2018-11-05T21:34:50.000000000Z                           7.5            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu0  2018-11-05T21:36:00.000000000Z  2018-11-05T21:35:00.000000000Z                          10.3            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu0  2018-11-05T21:36:00.000000000Z  2018-11-05T21:35:10.000000000Z                           9.2            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu0  2018-11-05T21:36:00.000000000Z  2018-11-05T21:35:20.000000000Z                           8.4            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu0  2018-11-05T21:36:00.000000000Z  2018-11-05T21:35:30.000000000Z                           8.5            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu0  2018-11-05T21:36:00.000000000Z  2018-11-05T21:35:40.000000000Z                           8.6            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu0  2018-11-05T21:36:00.000000000Z  2018-11-05T21:35:50.000000000Z                          10.2            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu0  2018-11-05T21:36:00.000000000Z  2018-11-05T21:36:00.000000000Z                          10.6            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [cpu]
            cpu:string                      _stop:time                      _time:time                  _value:float           _field:string     _measurement:string                     _start:time
----------------------  ------------------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
                  cpu1  2018-11-05T21:36:00.000000000Z  2018-11-05T21:34:00.000000000Z            0.7992007992007992            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu1  2018-11-05T21:36:00.000000000Z  2018-11-05T21:34:10.000000000Z                           0.7            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu1  2018-11-05T21:36:00.000000000Z  2018-11-05T21:34:20.000000000Z                           0.7            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu1  2018-11-05T21:36:00.000000000Z  2018-11-05T21:34:30.000000000Z                           0.4            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu1  2018-11-05T21:36:00.000000000Z  2018-11-05T21:34:40.000000000Z                           0.7            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu1  2018-11-05T21:36:00.000000000Z  2018-11-05T21:34:50.000000000Z                           0.7            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu1  2018-11-05T21:36:00.000000000Z  2018-11-05T21:35:00.000000000Z                           1.4            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu1  2018-11-05T21:36:00.000000000Z  2018-11-05T21:35:10.000000000Z                           1.2            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu1  2018-11-05T21:36:00.000000000Z  2018-11-05T21:35:20.000000000Z                           0.8            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu1  2018-11-05T21:36:00.000000000Z  2018-11-05T21:35:30.000000000Z            0.8991008991008991            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu1  2018-11-05T21:36:00.000000000Z  2018-11-05T21:35:40.000000000Z            0.8008008008008008            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu1  2018-11-05T21:36:00.000000000Z  2018-11-05T21:35:50.000000000Z             0.999000999000999            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu1  2018-11-05T21:36:00.000000000Z  2018-11-05T21:36:00.000000000Z            1.1022044088176353            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [cpu]
            cpu:string                      _stop:time                      _time:time                  _value:float           _field:string     _measurement:string                     _start:time
----------------------  ------------------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
                  cpu2  2018-11-05T21:36:00.000000000Z  2018-11-05T21:34:00.000000000Z                           4.1            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu2  2018-11-05T21:36:00.000000000Z  2018-11-05T21:34:10.000000000Z                           3.6            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu2  2018-11-05T21:36:00.000000000Z  2018-11-05T21:34:20.000000000Z                           3.5            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu2  2018-11-05T21:36:00.000000000Z  2018-11-05T21:34:30.000000000Z                           2.6            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu2  2018-11-05T21:36:00.000000000Z  2018-11-05T21:34:40.000000000Z                           4.5            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu2  2018-11-05T21:36:00.000000000Z  2018-11-05T21:34:50.000000000Z             4.895104895104895            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu2  2018-11-05T21:36:00.000000000Z  2018-11-05T21:35:00.000000000Z             6.906906906906907            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu2  2018-11-05T21:36:00.000000000Z  2018-11-05T21:35:10.000000000Z                           5.7            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu2  2018-11-05T21:36:00.000000000Z  2018-11-05T21:35:20.000000000Z                           5.1            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu2  2018-11-05T21:36:00.000000000Z  2018-11-05T21:35:30.000000000Z                           4.7            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu2  2018-11-05T21:36:00.000000000Z  2018-11-05T21:35:40.000000000Z                           5.1            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu2  2018-11-05T21:36:00.000000000Z  2018-11-05T21:35:50.000000000Z                           5.9            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu2  2018-11-05T21:36:00.000000000Z  2018-11-05T21:36:00.000000000Z            6.4935064935064934            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [cpu]
            cpu:string                      _stop:time                      _time:time                  _value:float           _field:string     _measurement:string                     _start:time
----------------------  ------------------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
                  cpu3  2018-11-05T21:36:00.000000000Z  2018-11-05T21:34:00.000000000Z            0.5005005005005005            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu3  2018-11-05T21:36:00.000000000Z  2018-11-05T21:34:10.000000000Z                           0.5            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu3  2018-11-05T21:36:00.000000000Z  2018-11-05T21:34:20.000000000Z                           0.5            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu3  2018-11-05T21:36:00.000000000Z  2018-11-05T21:34:30.000000000Z                           0.3            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu3  2018-11-05T21:36:00.000000000Z  2018-11-05T21:34:40.000000000Z                           0.6            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu3  2018-11-05T21:36:00.000000000Z  2018-11-05T21:34:50.000000000Z                           0.6            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu3  2018-11-05T21:36:00.000000000Z  2018-11-05T21:35:00.000000000Z            1.3986013986013985            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu3  2018-11-05T21:36:00.000000000Z  2018-11-05T21:35:10.000000000Z                           0.9            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu3  2018-11-05T21:36:00.000000000Z  2018-11-05T21:35:20.000000000Z            0.5005005005005005            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu3  2018-11-05T21:36:00.000000000Z  2018-11-05T21:35:30.000000000Z                           0.7            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu3  2018-11-05T21:36:00.000000000Z  2018-11-05T21:35:40.000000000Z                           0.6            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu3  2018-11-05T21:36:00.000000000Z  2018-11-05T21:35:50.000000000Z                           0.8            usage_system                     cpu  2018-11-05T21:34:00.000000000Z
                  cpu3  2018-11-05T21:36:00.000000000Z  2018-11-05T21:36:00.000000000Z                           0.9            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

可视化效果保持不变。

Group by CPU

按时间分组

_time 列对数据进行分组很好地说明了分组如何更改数据的结构。

dataSet
    |> group(columns: ["_time"])

_time 分组时,所有共享通用 _time 值的记录都将分组到各个表中。因此,每个输出表代表时间上的一个点。

按时间分组输出表
Table: keys: [_time]
                    _time:time                     _start:time                      _stop:time                  _value:float           _field:string     _measurement:string              cpu:string
------------------------------  ------------------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ----------------------
2018-11-05T21:34:00.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z             7.892107892107892            usage_system                     cpu                    cpu0
2018-11-05T21:34:00.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            0.7992007992007992            usage_system                     cpu                    cpu1
2018-11-05T21:34:00.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           4.1            usage_system                     cpu                    cpu2
2018-11-05T21:34:00.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            0.5005005005005005            usage_system                     cpu                    cpu3

Table: keys: [_time]
                    _time:time                     _start:time                      _stop:time                  _value:float           _field:string     _measurement:string              cpu:string
------------------------------  ------------------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ----------------------
2018-11-05T21:34:10.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           7.2            usage_system                     cpu                    cpu0
2018-11-05T21:34:10.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           0.7            usage_system                     cpu                    cpu1
2018-11-05T21:34:10.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           3.6            usage_system                     cpu                    cpu2
2018-11-05T21:34:10.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           0.5            usage_system                     cpu                    cpu3

Table: keys: [_time]
                    _time:time                     _start:time                      _stop:time                  _value:float           _field:string     _measurement:string              cpu:string
------------------------------  ------------------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ----------------------
2018-11-05T21:34:20.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           7.4            usage_system                     cpu                    cpu0
2018-11-05T21:34:20.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           0.7            usage_system                     cpu                    cpu1
2018-11-05T21:34:20.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           3.5            usage_system                     cpu                    cpu2
2018-11-05T21:34:20.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           0.5            usage_system                     cpu                    cpu3

Table: keys: [_time]
                    _time:time                     _start:time                      _stop:time                  _value:float           _field:string     _measurement:string              cpu:string
------------------------------  ------------------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ----------------------
2018-11-05T21:34:30.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           5.5            usage_system                     cpu                    cpu0
2018-11-05T21:34:30.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           0.4            usage_system                     cpu                    cpu1
2018-11-05T21:34:30.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           2.6            usage_system                     cpu                    cpu2
2018-11-05T21:34:30.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           0.3            usage_system                     cpu                    cpu3

Table: keys: [_time]
                    _time:time                     _start:time                      _stop:time                  _value:float           _field:string     _measurement:string              cpu:string
------------------------------  ------------------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ----------------------
2018-11-05T21:34:40.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           7.4            usage_system                     cpu                    cpu0
2018-11-05T21:34:40.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           0.7            usage_system                     cpu                    cpu1
2018-11-05T21:34:40.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           4.5            usage_system                     cpu                    cpu2
2018-11-05T21:34:40.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           0.6            usage_system                     cpu                    cpu3

Table: keys: [_time]
                    _time:time                     _start:time                      _stop:time                  _value:float           _field:string     _measurement:string              cpu:string
------------------------------  ------------------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ----------------------
2018-11-05T21:34:50.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           7.5            usage_system                     cpu                    cpu0
2018-11-05T21:34:50.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           0.7            usage_system                     cpu                    cpu1
2018-11-05T21:34:50.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z             4.895104895104895            usage_system                     cpu                    cpu2
2018-11-05T21:34:50.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           0.6            usage_system                     cpu                    cpu3

Table: keys: [_time]
                    _time:time                     _start:time                      _stop:time                  _value:float           _field:string     _measurement:string              cpu:string
------------------------------  ------------------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ----------------------
2018-11-05T21:35:00.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                          10.3            usage_system                     cpu                    cpu0
2018-11-05T21:35:00.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           1.4            usage_system                     cpu                    cpu1
2018-11-05T21:35:00.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z             6.906906906906907            usage_system                     cpu                    cpu2
2018-11-05T21:35:00.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            1.3986013986013985            usage_system                     cpu                    cpu3

Table: keys: [_time]
                    _time:time                     _start:time                      _stop:time                  _value:float           _field:string     _measurement:string              cpu:string
------------------------------  ------------------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ----------------------
2018-11-05T21:35:10.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           9.2            usage_system                     cpu                    cpu0
2018-11-05T21:35:10.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           1.2            usage_system                     cpu                    cpu1
2018-11-05T21:35:10.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           5.7            usage_system                     cpu                    cpu2
2018-11-05T21:35:10.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           0.9            usage_system                     cpu                    cpu3

Table: keys: [_time]
                    _time:time                     _start:time                      _stop:time                  _value:float           _field:string     _measurement:string              cpu:string
------------------------------  ------------------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ----------------------
2018-11-05T21:35:20.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           8.4            usage_system                     cpu                    cpu0
2018-11-05T21:35:20.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           0.8            usage_system                     cpu                    cpu1
2018-11-05T21:35:20.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           5.1            usage_system                     cpu                    cpu2
2018-11-05T21:35:20.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            0.5005005005005005            usage_system                     cpu                    cpu3

Table: keys: [_time]
                    _time:time                     _start:time                      _stop:time                  _value:float           _field:string     _measurement:string              cpu:string
------------------------------  ------------------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ----------------------
2018-11-05T21:35:30.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           8.5            usage_system                     cpu                    cpu0
2018-11-05T21:35:30.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            0.8991008991008991            usage_system                     cpu                    cpu1
2018-11-05T21:35:30.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           4.7            usage_system                     cpu                    cpu2
2018-11-05T21:35:30.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           0.7            usage_system                     cpu                    cpu3

Table: keys: [_time]
                    _time:time                     _start:time                      _stop:time                  _value:float           _field:string     _measurement:string              cpu:string
------------------------------  ------------------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ----------------------
2018-11-05T21:35:40.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           8.6            usage_system                     cpu                    cpu0
2018-11-05T21:35:40.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            0.8008008008008008            usage_system                     cpu                    cpu1
2018-11-05T21:35:40.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           5.1            usage_system                     cpu                    cpu2
2018-11-05T21:35:40.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           0.6            usage_system                     cpu                    cpu3

Table: keys: [_time]
                    _time:time                     _start:time                      _stop:time                  _value:float           _field:string     _measurement:string              cpu:string
------------------------------  ------------------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ----------------------
2018-11-05T21:35:50.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                          10.2            usage_system                     cpu                    cpu0
2018-11-05T21:35:50.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z             0.999000999000999            usage_system                     cpu                    cpu1
2018-11-05T21:35:50.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           5.9            usage_system                     cpu                    cpu2
2018-11-05T21:35:50.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           0.8            usage_system                     cpu                    cpu3

Table: keys: [_time]
                    _time:time                     _start:time                      _stop:time                  _value:float           _field:string     _measurement:string              cpu:string
------------------------------  ------------------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ----------------------
2018-11-05T21:36:00.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                          10.6            usage_system                     cpu                    cpu0
2018-11-05T21:36:00.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            1.1022044088176353            usage_system                     cpu                    cpu1
2018-11-05T21:36:00.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z            6.4935064935064934            usage_system                     cpu                    cpu2
2018-11-05T21:36:00.000000000Z  2018-11-05T21:34:00.000000000Z  2018-11-05T21:36:00.000000000Z                           0.9            usage_system                     cpu                    cpu3

由于每个时间戳都构造为单独的表,因此在可视化时,所有共享同一时间戳的点都显示为已连接。

Group by time

通过一些进一步的处理,您可以计算每个时间点所有 CPU 的平均 CPU 使用率,并将它们分组到一个表中,但在此示例中我们不介绍这一点。如果您有兴趣自己运行和可视化此操作,则以下是查询的样子

dataSet
    |> group(columns: ["_time"])
    |> mean()
    |> group(columns: ["_value", "_time"], mode: "except")

按 CPU 和时间分组

cpu_time 列分组。

dataSet
    |> group(columns: ["cpu", "_time"])

这将为每个唯一的 cpu_time 组合输出一个表

按 CPU 和时间分组输出表
Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:34:00.000000000Z                    cpu0  2018-11-05T21:36:00.000000000Z             7.892107892107892            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:34:00.000000000Z                    cpu1  2018-11-05T21:36:00.000000000Z            0.7992007992007992            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:34:00.000000000Z                    cpu2  2018-11-05T21:36:00.000000000Z                           4.1            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:34:00.000000000Z                    cpu3  2018-11-05T21:36:00.000000000Z            0.5005005005005005            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:34:10.000000000Z                    cpu0  2018-11-05T21:36:00.000000000Z                           7.2            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:34:10.000000000Z                    cpu1  2018-11-05T21:36:00.000000000Z                           0.7            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:34:10.000000000Z                    cpu2  2018-11-05T21:36:00.000000000Z                           3.6            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:34:10.000000000Z                    cpu3  2018-11-05T21:36:00.000000000Z                           0.5            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:34:20.000000000Z                    cpu0  2018-11-05T21:36:00.000000000Z                           7.4            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:34:20.000000000Z                    cpu1  2018-11-05T21:36:00.000000000Z                           0.7            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:34:20.000000000Z                    cpu2  2018-11-05T21:36:00.000000000Z                           3.5            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:34:20.000000000Z                    cpu3  2018-11-05T21:36:00.000000000Z                           0.5            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:34:30.000000000Z                    cpu0  2018-11-05T21:36:00.000000000Z                           5.5            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:34:30.000000000Z                    cpu1  2018-11-05T21:36:00.000000000Z                           0.4            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:34:30.000000000Z                    cpu2  2018-11-05T21:36:00.000000000Z                           2.6            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:34:30.000000000Z                    cpu3  2018-11-05T21:36:00.000000000Z                           0.3            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:34:40.000000000Z                    cpu0  2018-11-05T21:36:00.000000000Z                           7.4            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:34:40.000000000Z                    cpu1  2018-11-05T21:36:00.000000000Z                           0.7            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:34:40.000000000Z                    cpu2  2018-11-05T21:36:00.000000000Z                           4.5            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:34:40.000000000Z                    cpu3  2018-11-05T21:36:00.000000000Z                           0.6            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:34:50.000000000Z                    cpu0  2018-11-05T21:36:00.000000000Z                           7.5            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:34:50.000000000Z                    cpu1  2018-11-05T21:36:00.000000000Z                           0.7            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:34:50.000000000Z                    cpu2  2018-11-05T21:36:00.000000000Z             4.895104895104895            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:34:50.000000000Z                    cpu3  2018-11-05T21:36:00.000000000Z                           0.6            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:35:00.000000000Z                    cpu0  2018-11-05T21:36:00.000000000Z                          10.3            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:35:00.000000000Z                    cpu1  2018-11-05T21:36:00.000000000Z                           1.4            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:35:00.000000000Z                    cpu2  2018-11-05T21:36:00.000000000Z             6.906906906906907            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:35:00.000000000Z                    cpu3  2018-11-05T21:36:00.000000000Z            1.3986013986013985            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:35:10.000000000Z                    cpu0  2018-11-05T21:36:00.000000000Z                           9.2            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:35:10.000000000Z                    cpu1  2018-11-05T21:36:00.000000000Z                           1.2            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:35:10.000000000Z                    cpu2  2018-11-05T21:36:00.000000000Z                           5.7            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:35:10.000000000Z                    cpu3  2018-11-05T21:36:00.000000000Z                           0.9            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:35:20.000000000Z                    cpu0  2018-11-05T21:36:00.000000000Z                           8.4            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:35:20.000000000Z                    cpu1  2018-11-05T21:36:00.000000000Z                           0.8            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:35:20.000000000Z                    cpu2  2018-11-05T21:36:00.000000000Z                           5.1            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:35:20.000000000Z                    cpu3  2018-11-05T21:36:00.000000000Z            0.5005005005005005            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:35:30.000000000Z                    cpu0  2018-11-05T21:36:00.000000000Z                           8.5            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:35:30.000000000Z                    cpu1  2018-11-05T21:36:00.000000000Z            0.8991008991008991            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:35:30.000000000Z                    cpu2  2018-11-05T21:36:00.000000000Z                           4.7            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:35:30.000000000Z                    cpu3  2018-11-05T21:36:00.000000000Z                           0.7            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:35:40.000000000Z                    cpu0  2018-11-05T21:36:00.000000000Z                           8.6            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:35:40.000000000Z                    cpu1  2018-11-05T21:36:00.000000000Z            0.8008008008008008            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:35:40.000000000Z                    cpu2  2018-11-05T21:36:00.000000000Z                           5.1            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:35:40.000000000Z                    cpu3  2018-11-05T21:36:00.000000000Z                           0.6            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:35:50.000000000Z                    cpu0  2018-11-05T21:36:00.000000000Z                          10.2            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:35:50.000000000Z                    cpu1  2018-11-05T21:36:00.000000000Z             0.999000999000999            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:35:50.000000000Z                    cpu2  2018-11-05T21:36:00.000000000Z                           5.9            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:35:50.000000000Z                    cpu3  2018-11-05T21:36:00.000000000Z                           0.8            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:36:00.000000000Z                    cpu0  2018-11-05T21:36:00.000000000Z                          10.6            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:36:00.000000000Z                    cpu1  2018-11-05T21:36:00.000000000Z            1.1022044088176353            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:36:00.000000000Z                    cpu2  2018-11-05T21:36:00.000000000Z            6.4935064935064934            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

Table: keys: [_time, cpu]
                    _time:time              cpu:string                      _stop:time                  _value:float           _field:string     _measurement:string                     _start:time
------------------------------  ----------------------  ------------------------------  ----------------------------  ----------------------  ----------------------  ------------------------------
2018-11-05T21:36:00.000000000Z                    cpu3  2018-11-05T21:36:00.000000000Z                           0.9            usage_system                     cpu  2018-11-05T21:34:00.000000000Z

可视化时,表显示为单独的、未连接的点。

Group by CPU and time

cpu_time 分组很好地说明了分组的工作原理。

总结

分组是将数据塑造为所需输出格式的强大方法。它修改输出表的分组键,将记录分组到所有在指定列中共享通用值的表中。


此页面是否对您有帮助?

感谢您的反馈!


Flux 的未来

Flux 即将进入维护模式。您可以继续像当前一样使用它,而无需对代码进行任何更改。

阅读更多

现已全面上市

InfluxDB 3 Core 和 Enterprise

快速启动。更快扩展。

获取更新

InfluxDB 3 Core 是一个开源、高速、最近数据引擎,可实时收集和处理数据,并将其持久保存到本地磁盘或对象存储。InfluxDB 3 Enterprise 以 Core 的基础为构建,增加了高可用性、读取副本、增强的安全性以及数据压缩,从而实现更快的查询和优化的存储。InfluxDB 3 Enterprise 的免费层可供非商业家庭或业余爱好者使用。

有关更多信息,请查看