目录
输入和输出集成概述
NATS Consumer 输入插件支持从 NATS 消息主题实时数据消费,无缝集成到 Telegraf 数据管道中,用于监控和指标收集。
此插件使 Telegraf 能够使用 InfluxDB 行协议将指标直接高效地写入 VictoriaMetrics,从而利用 VictoriaMetrics 的性能和可扩展性功能处理大规模时序数据。
集成详情
NATS
NATS Consumer 插件允许 Telegraf 从指定的 NATS 主题读取指标,并根据支持的输入数据格式创建指标。利用队列组允许多个 Telegraf 实例并行从 NATS 集群读取数据,从而提高吞吐量和可靠性。此插件还支持各种身份验证方法,包括用户名/密码、NATS 凭据文件和 nkey 种子文件,确保与 NATS 服务器的安全通信。由于 JetStream 等功能有助于消费历史消息,因此在数据持久性和消息可靠性至关重要的环境中,此插件特别有用。此外,配置各种操作参数的能力使此插件适用于高吞吐量场景,同时保持性能完整性。
VictoriaMetrics
VictoriaMetrics 支持直接摄取 InfluxDB 行协议中的指标,这使得此插件成为高效实时指标存储和检索的理想选择。该集成结合了 Telegraf 广泛的指标收集功能和 VictoriaMetrics 优化的存储和查询功能,包括压缩、快速摄取率和高效的磁盘利用率。此插件非常适合云原生和大规模监控场景,它提供了简洁性、强大的性能和高可靠性,为大量指标实现高级操作洞察和长期存储解决方案。
配置
NATS
[[inputs.nats_consumer]]
## urls of NATS servers
servers = ["nats://localhost:4222"]
## subject(s) to consume
## If you use jetstream you need to set the subjects
## in jetstream_subjects
subjects = ["telegraf"]
## jetstream subjects
## jetstream is a streaming technology inside of nats.
## With jetstream the nats-server persists messages and
## a consumer can consume historical messages. This is
## useful when telegraf needs to restart it don't miss a
## message. You need to configure the nats-server.
## https://docs.nats.io/nats-concepts/jetstream.
jetstream_subjects = ["js_telegraf"]
## name a queue group
queue_group = "telegraf_consumers"
## Optional authentication with username and password credentials
# username = ""
# password = ""
## Optional authentication with NATS credentials file (NATS 2.0)
# credentials = "/etc/telegraf/nats.creds"
## Optional authentication with nkey seed file (NATS 2.0)
# nkey_seed = "/etc/telegraf/seed.txt"
## Use Transport Layer Security
# secure = 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
## Sets the limits for pending msgs and bytes for each subscription
## These shouldn't need to be adjusted except in very high throughput scenarios
# pending_message_limit = 65536
# pending_bytes_limit = 67108864
## Max undelivered messages
## This plugin uses tracking metrics, which ensure messages are read to
## outputs before acknowledging them to the original broker to ensure data
## is not lost. This option sets the maximum messages to read from the
## broker that have not been written by an output.
##
## This value needs to be picked with awareness of the agent's
## metric_batch_size value as well. Setting max undelivered messages too high
## can result in a constant stream of data batches to the output. While
## setting it too low may never flush the broker's messages.
# max_undelivered_messages = 1000
## Data format to consume.
## Each data format has its own unique set of configuration options, read
## more about them here:
## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
data_format = "influx"
VictoriaMetrics
[[outputs.influxdb]]
## URL of the VictoriaMetrics write endpoint
urls = ["http://localhost:8428"]
## VictoriaMetrics accepts InfluxDB line protocol directly
database = "db_name"
## Optional authentication
# username = "username"
# password = "password"
# skip_database_creation = true
# exclude_retention_policy_tag = true
# content_encoding = "gzip"
## Timeout for HTTP requests
timeout = "5s"
## Optional TLS configuration
# tls_ca = "/path/to/ca.pem"
# tls_cert = "/path/to/cert.pem"
# tls_key = "/path/to/key.pem"
# insecure_skip_verify = false
输入和输出集成示例
NATS
-
实时分析仪表板:利用 NATS 插件实时收集来自各种 NATS 主题的指标,并将它们馈送到中央分析仪表板中。此设置可以立即查看实时应用程序性能,使团队能够快速响应操作问题或性能下降。
-
分布式系统监控:在分布式架构中部署配置了 NATS 插件的多个 Telegraf 实例。这种方法使团队能够有效地聚合来自各种微服务的指标,从而提供系统健康和性能的整体视图,同时确保在传输过程中不会丢弃任何消息。
-
历史消息恢复:利用 NATS JetStream 的功能以及此插件,在 Telegraf 重新启动后恢复和处理历史消息。此功能对于需要高可靠性的应用程序特别有益,确保即使在服务中断的情况下也不会丢失任何关键指标。
-
动态负载均衡:实施动态负载均衡场景,其中 Telegraf 实例根据负载从 NATS 集群消费消息。调整队列组设置以控制活动消费者的数量,从而在需求波动时实现更好的资源利用率和性能扩展。
VictoriaMetrics
-
云原生应用程序监控:将部署在 Kubernetes 上的微服务的指标直接流式传输到 VictoriaMetrics 中。通过集中指标,组织可以在动态发展的云环境中执行实时监控、快速异常检测和无缝可扩展性。
-
可扩展的物联网数据管理:使用此插件将来自物联网部署的传感器数据摄取到 VictoriaMetrics 中。这种方法有助于实时分析、预测性维护以及以最小的存储开销高效管理海量传感器数据。
-
金融系统性能跟踪:通过此插件利用 VictoriaMetrics 存储和分析来自金融系统的指标,捕获延迟、交易量和错误率。组织可以快速识别和解决性能瓶颈,确保高可用性和法规遵从性。
-
跨环境性能仪表板:将来自各种基础设施组件(例如云实例、容器和物理服务器)的指标集成到 VictoriaMetrics 中。使用可视化工具,团队可以构建全面的仪表板,用于端到端性能可见性、主动故障排除和基础设施优化。
反馈
感谢您成为我们社区的一份子!如果您有任何一般性反馈或在这些页面上发现任何错误,我们欢迎并鼓励您提出意见。请在 InfluxDB 社区 Slack 中提交您的反馈。