文档文档

Health Output Plugin

此插件提供了一个 HTTP 健康检查端点,可以配置为根据指标值返回失败状态码。

当插件健康时,它将返回 200 响应;当不健康时,它将返回 503 响应。默认状态为健康,必须有一个或多个检查失败,资源才能进入失败状态。

引入于: Telegraf v1.11.0 标签: applications 操作系统支持: all

全局配置选项

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

配置

# Configurable HTTP health check resource based on metrics
[[outputs.health]]
  ## Address and port to listen on.
  ##   ex: service_address = "https://:8080"
  ##       service_address = "unix:///var/run/telegraf-health.sock"
  # service_address = "http://:8080"

  ## The maximum duration for reading the entire request.
  # read_timeout = "5s"
  ## The maximum duration for writing the entire response.
  # write_timeout = "5s"

  ## Username and password to accept for HTTP basic authentication.
  # basic_username = "user1"
  # basic_password = "secret"

  ## Allowed CA certificates for client certificates.
  # tls_allowed_cacerts = ["/etc/telegraf/clientca.pem"]

  ## TLS server certificate and private key.
  # tls_cert = "/etc/telegraf/cert.pem"
  # tls_key = "/etc/telegraf/key.pem"

  ## Maximum expected time between metrics being written
  ## Enforces an unhealthy state if there was no new metric seen for at least
  ## the specified time. The check is disabled by default and only used if a
  ## positive time is specified.
  # max_time_between_metrics = "0s"

  ## NOTE: Due to the way TOML is parsed, tables must be at the END of the
  ## plugin definition, otherwise additional config options are read as part of
  ## the table

  ## One or more check sub-tables should be defined, it is also recommended to
  ## use metric filtering to limit the metrics that flow into this output.
  ##
  ## When using the default buffer sizes, this example will fail when the
  ## metric buffer is half full.
  ##
  ## namepass = ["internal_write"]
  ## tagpass = { output = ["influxdb"] }
  ##
  ## [[outputs.health.compares]]
  ##   field = "buffer_size"
  ##   lt = 5000.0
  ##
  ## [[outputs.health.contains]]
  ##   field = "buffer_size"

两次指标之间的最大时间间隔

当将 max_time_between_metrics 设置为正数时,health 插件可以断言指标以预期的速率发送给它。该检查衡量插件连续写入之间的时间,并将其与定义的 max_time_between_metrics 进行比较。当写入之间的时间间隔大于配置的最大时间时,插件将报告不健康状态。一旦再次向插件写入指标,健康状态将重置为健康。

请注意,指标的时间戳不被考虑在内,而是它们被写入插件的时间。

compares

compares 检查用于断言基本的数学关系。通过选择一个字段键和一个或多个必须为真的比较来实现。如果指标上找不到该字段,则不会进行任何比较。

检查必须对所有指标都为真才能通过。

可用的比较运算符有:

  • gt 大于
  • ge 大于或等于
  • lt 小于
  • le 小于或等于
  • eq 等于
  • ne 不等于

contains

contains 检查可用于要求至少一个指标存在某个字段键。

如果在任何指标上找到该字段,则检查通过。


此页面是否有帮助?

感谢您的反馈!


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