OpenSource-Hub

telegraf

命令行工具

influxdata/telegraf

用于收集、处理和写入指标、日志等数据的代理。

项目简介

Telegraf 是一个基于插件的服务端代理,从数据库、系统和 IoT 传感器收集并发送指标和事件。支持超过 300 个输入、输出和聚合插件,编译为无外部依赖的静态二进制文件。

README 预览

#  Telegraf\n\n[](https://godoc.org/github.com/influxdata/telegraf)\n[](https://hub.docker.com/_/telegraf/)\n[](https://goreportcard.com/report/github.com/influxdata/telegraf)\n[](https://circleci.com/gh/influxdata/telegraf)\n\nTelegraf is an agent for collecting, processing, aggregating, and writing\nmetrics, logs, and other arbitrary data.\n\n* Offers a comprehensive suite of over 300 plugins, covering a wide range of\n  functionalities including system monitoring, cloud services, and message\n  passing\n* Enables the integration of user-defined code to collect, transform, and\n  transmit data efficiently\n* Compiles into a standalone static binary without any external dependencies,\n  ensuring a streamlined deployment process\n* Utilizes TOML for configuration, providing a user-friendly and unambiguous\n  setup experience\n* Developed with contributions from a diverse community of over 1,200\n  contributors\n\nUsers can choose plugins from a wide range of topics, including but not limited\nto:\n\n* Devices: [OPC UA][], [Modbus][]\n* Logs: [File][], [Tail][], [Directory Monitor][]\n* Messaging: [AMQP][], [Kafka][], [MQTT][]\n* Monitoring: [OpenTelemetry][], [Prometheus][]\n* Networking: [Cisco TelemetryMDT][], [gNMI][]\n* System monitoring: [CPU][], [Memory][], [Disk][], [Network][], [SMART][],\n  [Docker][], [Nvidia SMI][], etc.\n* Universal: [Exec][], [HTTP][], [HTTP Listener][], [SNMP][], [SQL][]\n* Windows: [Event Log][], [Management Instrumentation][],\n  [Performance Counters][]\n\n## 🔨 Installation\n\nFor binary builds, Docker images, RPM & DEB packages, and other builds of\nTelegraf, please see the [install guide](/docs/INSTALL_GUIDE.md).\n\nSee the [releases documentation](/docs/RELEASES.md) for details on versioning\nand when releases are made.\n\n## 💻 Usage\n\nUsers define a TOML configuration with the plugins and settings they wish to\nuse, then pass that configuration to Telegraf. The Telegraf agent then\ncollects data from inputs at each interval a

常见问题 (4)

故障排除
如何修复Telegraf OPC UA监听器在监控超过1150个节点时出现的'EOF'错误?

这是一个已知的错误(问题 #14568),当许多节点配置了安全连接时,OPC UA 监听器插件会发送过大的请求。服务器以 'BadTcpMessageTooLarge' 拒绝该请求,导致 'EOF' 错误。解决方法:将节点分成大约 500 个一组,分散到多个 [[inputs.opcua_listener]] 实例或 group 块中。正在开发一个永久性的批处理修复方案。

来源 Issue #16548
故障排除
为什么Telegraf的系统运行时间指标在Prometheus中以gauge类型报告?

Telegraf(未发布的1.39.0版本)中的一个错误将'uptime'指标错误地注册为gauge(仪表)类型。正确的类型应为counter(计数器),因为uptime只会递增。该问题将在正式发布前修复。对于受影响的开发构建版本,可通过在Prometheus中使用metric_relabel_configs或relabeling规则覆盖指标类型,将其视为counter。修复后请升级至最新的稳定版本。

来源 Issue #18952
故障排除
为什么即使配置了 statefile,Telegraf 的 docker_log 输入插件在重启后仍会重新发送旧日志?

状态文件仅在正常关闭时写入。如果使用 docker compose downdocker compose up -d,容器可能在状态持久化之前被杀死。解决办法:先使用 docker compose stop 正常停止 Telegraf,然后运行 docker compose downdocker compose up -d。确保关闭日志显示 "Persisting plugin states"。您也可以增加停止超时时间(stop_grace_period: 30s),以允许 Telegraf 刷新并持久化数据。

来源 Issue #18059
故障排除
为什么Telegraf磁盘插件报告mode=rw对于一个只读挂载的文件系统?

这是gopsutil(disk_linux.go)中的一个已知bug,它依赖/etc/mtab而非/proc/mounts。该问题已在Telegraf ≥1.14.0中修复。请升级至最新版Telegraf或应用以下解决方案:确保文件系统在/proc/mounts中明确标记为'ro',且未被ignore_fs排除。

来源 Issue #6633