文档文档

Socket Statistics Input Plugin

此插件使用 iproute2ss 命令收集有关已建立网络连接的指标。ss 命令不需要特定权限。

此插件会产生高基数数据,如果不加以控制,将对数据库造成高负载。请务必过滤生成的指标或配置您的数据库以避免基数问题!

引入于: Telegraf v1.22.0 标签: network 操作系统支持: freebsd, linux, macos

全局配置选项

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

配置

# Gather indicators from established connections, using iproute2's ss command.
# This plugin ONLY supports non-Windows
[[inputs.socketstat]]
  ## ss can display information about tcp, udp, raw, unix, packet, dccp and sctp sockets
  ## Specify here the types you want to gather
  protocols = [ "tcp", "udp" ]

  ## The default timeout of 1s for ss execution can be overridden here:
  # timeout = "1s"

Metrics

socketstat 测量包含以下字段

  • state (string) (适用于 tcp, dccp 和 sctp 协议)

如果 ss 提供(取决于协议和 ss 版本),它还有以下附加字段

  • bytes_acked (integer, bytes)
  • bytes_received (integer, bytes)
  • segs_out (integer, count)
  • segs_in (integer, count)
  • data_segs_out (integer, count)
  • data_segs_in (integer, count)

所有测量值都有以下标签

  • proto
  • local_addr
  • local_port
  • remote_addr
  • remote_port

示例输出

较新版本的 ss (这里是 iproute2 4.3.0)

./telegraf --config telegraf.conf --input-filter socketstat --test
socketstat,host=ubuntu-xenial,local_addr=10.6.231.226,local_port=42716,proto=tcp,remote_addr=192.168.2.21,remote_port=80 bytes_acked=184i,bytes_received=2624519595i,recv_q=4344i,segs_in=1812580i,segs_out=661642i,send_q=0i,state="ESTAB" 1606457205000000000

较旧版本的 ss (这里是 iproute2 3.12.0)

./telegraf --config telegraf.conf --input-filter socketstat --test
socketstat,host=ubuntu-trusty,local_addr=10.6.231.163,local_port=35890,proto=tcp,remote_addr=192.168.2.21,remote_port=80 recv_q=0i,send_q=0i,state="ESTAB" 1606456977000000000

此页面是否有帮助?

感谢您的反馈!


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