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 检查可用于要求至少一个指标存在某个字段键。
如果在任何指标上找到该字段,则检查通过。
此页面是否有帮助?
感谢您的反馈!
支持和反馈
感谢您成为我们社区的一员!我们欢迎并鼓励您对 Telegraf 和本文档提出反馈和 bug 报告。要获取支持,请使用以下资源
具有年度合同或支持合同的客户可以 联系 InfluxData 支持。