文档文档

HAProxy 输入插件

此插件使用套接字或 HTTP 协议收集 HAProxy 服务器的统计信息。

引入于: Telegraf v0.1.5 标签: network, server 操作系统支持: all

全局配置选项

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

配置

# Read metrics of HAProxy, via stats socket or http endpoints
[[inputs.haproxy]]
  ## List of stats endpoints. Metrics can be collected from both http and socket
  ## endpoints. Examples of valid endpoints:
  ##   - http://myhaproxy.com:1936/haproxy?stats
  ##   - https://myhaproxy.com:8000/stats
  ##   - socket:/run/haproxy/admin.sock
  ##   - /run/haproxy/*.sock
  ##   - tcp://127.0.0.1:1936
  ##
  ## Server addresses not starting with 'http://', 'https://', 'tcp://' will be
  ## treated as possible sockets. When specifying local socket, glob patterns are
  ## supported.
  servers = ["http://myhaproxy.com:1936/haproxy?stats"]

  ## By default, some of the fields are renamed from what haproxy calls them.
  ## Setting this option to true results in the plugin keeping the original
  ## field names.
  # keep_field_names = false

  ## 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

HAProxy 配置

以下信息在开始使用时可能会有所帮助,但请参考 HAProxy 文档以获取完整和最新的说明。

可以通过 stats enable 选项来添加使用默认设置的未授权 HTTP 访问。要启用 Unix 套接字,请先阅读关于 stats socket 选项的说明。

servers

如果您希望使用 HAProxy 状态页面,服务器地址必须明确以“http”开头。否则,地址将被假定为 UNIX 套接字,并且任何协议(如果存在)都将被丢弃。

使用套接字名称时,支持通配符扩展,因此插件可以一次性收集多个套接字的状态。

要使用 HTTP Basic Auth,请在 URL 的 userinfo 部分添加用户名和密码:http://user:password@1.2.3.4/haproxy?stats。凭证通过 Authorization 头发送,而不是通过请求 URL。

keep_field_names

默认情况下,一些字段会被重命名,使其与 haproxy 的命名不同。将 keep_field_names 参数设置为 true 将使插件保留原始字段名称。

进行了以下重命名

  • pxname -> proxy
  • svname -> sv
  • act -> active_servers
  • bck -> backup_servers
  • cli_abrt -> cli_abort
  • srv_abrt -> srv_abort
  • hrsp_1xx -> http_response.1xx
  • hrsp_2xx -> http_response.2xx
  • hrsp_3xx -> http_response.3xx
  • hrsp_4xx -> http_response.4xx
  • hrsp_5xx -> http_response.5xx
  • hrsp_other -> http_response.other

Metrics

有关收集到的指标的更多详细信息,请参考 HAProxy CSV 格式文档

  • haproxy
    • 标签 (tags)
      • server - 收集数据的服务器地址
      • proxy - 代理名称
      • sv - 服务名称
      • type - 代理会话类型
    • 字段 (fields)
      • status (string)
      • check_status (string)
      • last_chk (string)
      • mode (string)
      • tracked (string)
      • agent_status (string)
      • last_agt (string)
      • addr (string)
      • cookie (string)
      • lastsess (int)
      • 所有其他统计信息 (int)

示例输出

haproxy,server=/run/haproxy/admin.sock,proxy=public,sv=FRONTEND,type=frontend http_response.other=0i,req_rate_max=1i,comp_byp=0i,status="OPEN",rate_lim=0i,dses=0i,req_rate=0i,comp_rsp=0i,bout=9287i,comp_in=0i,mode="http",smax=1i,slim=2000i,http_response.1xx=0i,conn_rate=0i,dreq=0i,ereq=0i,iid=2i,rate_max=1i,http_response.2xx=1i,comp_out=0i,intercepted=1i,stot=2i,pid=1i,http_response.5xx=1i,http_response.3xx=0i,http_response.4xx=0i,conn_rate_max=1i,conn_tot=2i,dcon=0i,bin=294i,rate=0i,sid=0i,req_tot=2i,scur=0i,dresp=0i 1513293519000000000

此页面是否有帮助?

感谢您的反馈!


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