文档文档

Nginx Upstream Check 输入插件

此插件使用 上游检查模块Nginx Web 服务器收集指标。该模块定期向 Nginx 的上游服务器发送配置的请求,以确定它们的可用性。

引入于: Telegraf v1.10.0 标签: server, web 操作系统支持: all

全局配置选项

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

配置

# Read nginx_upstream_check module status information (https://github.com/yaoweibin/nginx_upstream_check_module)
[[inputs.nginx_upstream_check]]
  ## An URL where Nginx Upstream check module is enabled
  ## It should be set to return a JSON formatted response
  url = "http://127.0.0.1/status?format=json"
  ## You can also point it at a unix socket too
  # url = "http+unix:///var/run/nginx.sock:/status?format=json"

  ## HTTP method
  # method = "GET"

  ## Optional HTTP headers
  # headers = {"X-Special-Header" = "Special-Value"}

  ## Override HTTP "Host" header
  # host_header = "check.example.com"

  ## Timeout for HTTP requests
  timeout = "5s"

  ## Optional HTTP Basic Auth credentials
  # username = "username"
  # password = "pa$$word"

  ## Optional TLS Config
  # tls_ca = "/etc/telegraf/ca.pem"
  # tls_cert = "/etc/telegraf/cert.pem"
  # tls_key = "/etc/telegraf/key.pem"
  ## Use TLS but skip chain & host verification
  # insecure_skip_verify = false

Metrics

  • Measurement
    • fall (失败的服务器检查尝试次数,计数器)
    • rise (成功的服务器检查尝试次数,计数器)
    • status (报告服务器状态的字符串)
    • status_code (服务器状态码。1 - up,2 - down,0 - other)

“status_code”字段最有可能最为有用,因为它允许您确定每台服务器的当前状态,并可能添加一些监控来监视它。InfluxDB 可以使用字符串值,“status”字段也可以替代使用,但对于大多数其他监控解决方案,整数代码将是合适的。

标签

  • 所有测量值都有以下标签
    • name (上游服务器的主机名或 IP)
    • port (替代检查端口,如果使用默认端口则为 0)
    • type (检查类型,http/tcp)
    • upstream (Nginx 配置中 upstream 块的名称)
    • url (telegraf 使用的状态 URL)

示例输出

运行时

./telegraf --config telegraf.conf --input-filter nginx_upstream_check --test

它会生成

nginx_upstream_check,host=node1,name=192.168.0.1:8080,port=0,type=http,upstream=my_backends,url=http://127.0.0.1:80/status?format\=json fall=0i,rise=100i,status="up",status_code=1i 1529088524000000000
nginx_upstream_check,host=node2,name=192.168.0.2:8080,port=0,type=http,upstream=my_backends,url=http://127.0.0.1:80/status?format\=json fall=100i,rise=0i,status="down",status_code=2i 1529088524000000000

此页面是否有帮助?

感谢您的反馈!


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