文档文档

直方图聚合器插件

此插件创建直方图,其中包含配置范围内字段值的计数。直方图指标每 period 发出一次。

cumulative 模式下,添加到存储桶的值也会添加到分布的连续存储桶中,创建一个累积直方图

默认情况下,存储桶计数在周期之间不会重置,在 Telegraf 运行时会非严格递增。可以通过设置 reset 参数来改变此行为。

引入版本: Telegraf v1.4.0 标签: statistics 操作系统支持: all

全局配置选项

插件支持其他全局和插件配置设置,用于修改指标、标签和字段,创建别名以及配置插件顺序等任务。更多详情请参阅 CONFIGURATION.md

配置

# Configuration for aggregate histogram metrics
[[aggregators.histogram]]
  ## The period in which to flush the aggregator.
  # period = "30s"

  ## If true, the original metric will be dropped by the
  ## aggregator and will not get sent to the output plugins.
  # drop_original = false

  ## If true, the histogram will be reset on flush instead
  ## of accumulating the results.
  reset = false

  ## Whether bucket values should be accumulated. If set to false, "gt" tag will be added.
  ## Defaults to true.
  cumulative = true

  ## Expiration interval for each histogram. The histogram will be expired if
  ## there are no changes in any buckets for this time interval. 0 == no expiration.
  # expiration_interval = "0m"

  ## If true, aggregated histogram are pushed to output only if it was updated since
  ## previous push. Defaults to false.
  # push_only_on_update = false

  ## Example config that aggregates all fields of the metric.
  # [[aggregators.histogram.config]]
  #   ## Right borders of buckets (with +Inf implicitly added).
  #   buckets = [0.0, 15.6, 34.5, 49.1, 71.5, 80.5, 94.5, 100.0]
  #   ## The name of metric.
  #   measurement_name = "cpu"

  ## Example config that aggregates only specific fields of the metric.
  # [[aggregators.histogram.config]]
  #   ## Right borders of buckets (with +Inf implicitly added).
  #   buckets = [0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0]
  #   ## The name of metric.
  #   measurement_name = "diskio"
  #   ## The concrete fields of metric
  #   fields = ["io_time", "read_time", "write_time"]

用户负责定义直方图桶的边界以及要聚合的测量名称和字段。

每个直方图配置节必须包含 bucketsmeasurement_name 选项。可选地,如果设置了 fields,则只聚合列出的字段。如果未设置 fields,则聚合所有字段。

buckets 选项包含一个浮点数列表,用于指定桶的边界。每个浮点数值定义了桶的包含性上限(右边界)。+Inf 桶会自动添加,无需定义。(对于左边界,将使用这些指定的桶边界和 -Inf)。

测量值 & 字段

后缀 bucket 将会添加到每个字段键中。

  • measurement1
    • field1_bucket
    • field2_bucket

标签

  • cumulative = true (默认)
    • le: 右桶边界。表示度量值小于或等于此标签的值。如果一个度量值被分入一个桶,它也会被分入所有更大的桶。因此,<field>_bucket 的值会随着 le 值的增大而增大。当 le+Inf 时,桶的值是所有度量的计数,因为所有度量值都小于或等于正无穷。
  • cumulative = false:
    • gt: 左桶边界。表示度量值大于(不等于)此标签的值。
    • le: 右桶边界。表示度量值小于或等于此标签的值。
    • 由于同时存在 gtle,每个度量值仅被分入一个精确的桶。

示例输出

假设我们有桶 [0, 10, 50, 100] 和 usage_idle 的以下字段值:[50, 7, 99, 12]

使用 cumulative = true

cpu,cpu=cpu1,host=localhost,le=0.0 usage_idle_bucket=0i 1486998330000000000  # none
cpu,cpu=cpu1,host=localhost,le=10.0 usage_idle_bucket=1i 1486998330000000000  # 7
cpu,cpu=cpu1,host=localhost,le=50.0 usage_idle_bucket=2i 1486998330000000000  # 7, 12
cpu,cpu=cpu1,host=localhost,le=100.0 usage_idle_bucket=4i 1486998330000000000  # 7, 12, 50, 99
cpu,cpu=cpu1,host=localhost,le=+Inf usage_idle_bucket=4i 1486998330000000000  # 7, 12, 50, 99

使用 cumulative = false

cpu,cpu=cpu1,host=localhost,gt=-Inf,le=0.0 usage_idle_bucket=0i 1486998330000000000  # none
cpu,cpu=cpu1,host=localhost,gt=0.0,le=10.0 usage_idle_bucket=1i 1486998330000000000  # 7
cpu,cpu=cpu1,host=localhost,gt=10.0,le=50.0 usage_idle_bucket=1i 1486998330000000000  # 12
cpu,cpu=cpu1,host=localhost,gt=50.0,le=100.0 usage_idle_bucket=2i 1486998330000000000  # 50, 99
cpu,cpu=cpu1,host=localhost,gt=100.0,le=+Inf usage_idle_bucket=0i 1486998330000000000  # none

此页面是否有帮助?

感谢您的反馈!


InfluxDB 3.8 新特性

InfluxDB 3.8 和 InfluxDB 3 Explorer 1.6 的主要增强功能。

查看博客文章

InfluxDB 3.8 现已适用于 Core 和 Enterprise 版本,同时发布了 InfluxDB 3 Explorer UI 的 1.6 版本。本次发布着重于操作成熟度,以及如何更轻松地部署、管理和可靠地运行 InfluxDB。

更多信息,请查看

InfluxDB Docker 的 latest 标签将指向 InfluxDB 3 Core

在 **2026 年 2 月 3 日**,InfluxDB Docker 镜像的 latest 标签将指向 InfluxDB 3 Core。为避免意外升级,请在您的 Docker 部署中使用特定的版本标签。

如果使用 Docker 来安装和运行 InfluxDB,latest 标签将指向 InfluxDB 3 Core。为避免意外升级,请在您的 Docker 部署中使用特定的版本标签。例如,如果使用 Docker 运行 InfluxDB v2,请将 latest 版本标签替换为 Docker pull 命令中的特定版本标签 — 例如

docker pull influxdb:2