目录
输入和输出集成概述
NATS Consumer Input 插件实现了从 NATS 消息主题实时数据消费,无缝集成到 Telegraf 数据管道中,用于监控和指标收集。
此插件允许使用 Metrics API 将指标发送到 New Relic Insights,从而实现对应用程序性能的有效监控和分析。
集成详情
NATS
NATS Consumer 插件允许 Telegraf 从指定的 NATS 主题读取指标,并基于支持的输入数据格式创建指标。利用队列组允许多个 Telegraf 实例并行地从 NATS 集群读取数据,从而提高吞吐量和可靠性。此插件还支持多种身份验证方法,包括用户名/密码、NATS 凭据文件和 nkey 种子文件,确保与 NATS 服务器的安全通信。由于 JetStream 等功能有助于历史消息的消费,因此该插件在数据持久性和消息可靠性至关重要的环境中尤其有用。此外,配置各种操作参数的能力使此插件适用于高吞吐量场景,同时保持性能完整性。
New Relic
此插件利用 Metrics API 将指标写入 New Relic Insights,Metrics API 为将时序数据发送到 New Relic 平台提供了强大的机制。用户必须首先获取 Insights API 密钥才能验证身份并授权其数据提交。该插件旨在促进与 New Relic 的监控和分析功能的轻松集成,支持各种指标类型,并允许高效的数据处理。核心功能包括能够为指标添加前缀以更好地识别、API 请求的可自定义超时以及对代理设置的支持以增强连接性。用户必须根据其需求配置这些选项,以便将数据无缝流入 New Relic,以实现全面的实时分析和洞察。
配置
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"
New Relic
[[outputs.newrelic]]
## The 'insights_key' parameter requires a NR license key.
## New Relic recommends you create one
## with a convenient name such as TELEGRAF_INSERT_KEY.
## reference: https://docs.newrelic.com/docs/apis/intro-apis/new-relic-api-keys/#ingest-license-key
# insights_key = "New Relic License Key Here"
## Prefix to add to add to metric name for easy identification.
## This is very useful if your metric names are ambiguous.
# metric_prefix = ""
## Timeout for writes to the New Relic API.
# timeout = "15s"
## HTTP Proxy override. If unset use values from the standard
## proxy environment variables to determine proxy, if any.
# http_proxy = "http://corporate.proxy:3128"
## Metric URL override to enable geographic location endpoints.
# If not set use values from the standard
# metric_url = "https://metric-api.newrelic.com/metric/v1"
输入和输出集成示例
NATS
-
实时分析仪表板:利用 NATS 插件实时收集来自各种 NATS 主题的指标,并将它们馈送到集中式分析仪表板。此设置允许立即查看实时应用程序性能,使团队能够快速响应操作问题或性能下降。
-
分布式系统监控:在分布式架构中部署多个配置了 NATS 插件的 Telegraf 实例。这种方法允许团队有效地聚合来自各种微服务的指标,提供系统健康和性能的整体视图,同时确保在传输过程中不会丢失任何消息。
-
历史消息恢复:利用 NATS JetStream 的功能以及此插件,在 Telegraf 重新启动后恢复和处理历史消息。此功能对于需要高可靠性的应用程序尤其有利,确保即使在服务中断的情况下也不会丢失任何关键指标。
-
动态负载均衡:实施动态负载均衡场景,其中 Telegraf 实例根据负载从 NATS 集群消费消息。调整队列组设置以控制活动消费者的数量,从而在需求波动时实现更好的资源利用和性能扩展。
New Relic
-
应用程序性能监控:使用 New Relic Telegraf 插件将来自 Web 服务的应用程序性能指标发送到 New Relic Insights。通过集成此插件,开发人员可以收集诸如响应时间、错误率和吞吐量等数据,使团队能够实时监控应用程序健康状况,并在问题影响用户之前快速解决问题。此设置促进了应用程序性能和用户体验的主动管理。
-
基础设施指标聚合:利用此插件聚合和发送来自各种服务器的系统级指标(CPU 使用率、内存消耗等)到 New Relic。这有助于系统管理员维护基础设施性能的全面视图,从而促进容量规划和识别潜在瓶颈。通过在 New Relic 中集中指标,团队可以可视化随时间变化的趋势,并就资源分配做出明智的决策。
-
多租户应用程序的动态指标命名:使用 metric_prefix 选项实施动态前缀,以区分多租户应用程序中的不同租户。通过配置插件以在指标名称中包含每个租户的唯一标识符,团队可以分析每个租户的使用模式和性能指标。这为租户行为提供了宝贵的见解,支持定制优化并提高跨不同客户群的服务质量。
-
实时异常检测:将 New Relic 插件与警报机制结合使用,以根据异常指标模式触发通知。通过发送诸如请求计数和响应时间之类的指标,团队可以在 New Relic 中设置阈值,当阈值被突破时,将自动提醒相关方。这种用户驱动的方法支持对潜在问题立即做出响应,以防止它们升级为更大的事件。
反馈
感谢您成为我们社区的一份子!如果您有任何一般性反馈或在这些页面上发现任何错误,我们欢迎并鼓励您提供意见。请在 InfluxDB 社区 Slack 中提交您的反馈。