NATS 输出插件
此插件以支持的数据格式之一将指标写入一组NATS 实例的主题。
引入于: Telegraf v1.1.0 标签: messaging 操作系统支持: all
全局配置选项
插件支持其他全局和插件配置设置,用于修改指标、标签和字段,创建别名以及配置插件顺序等任务。更多详情请参阅 CONFIGURATION.md。
Secret-store 支持
此插件支持来自 secret-stores 的 username、password 和 credential 选项的 secret。有关如何使用它们的更多详细信息,请参阅 secret-store 文档。
配置
# Send telegraf measurements to NATS
[[outputs.nats]]
## URLs of NATS servers
servers = ["nats://:4222"]
## Optional client name
# name = ""
## Optional credentials
# username = ""
# password = ""
## Optional NATS 2.0 and NATS NGS compatible user credentials
# credentials = ""
## Optional authentication with nkey seed file (NATS 2.0)
# nkey_seed = "/etc/telegraf/seed.txt"
## NATS subject for producer messages.
## This field can be a static string or a Go template, see README for details.
## Incompatible with `use_batch_format
subject = "telegraf"
## 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
## Use batch serialization instead of per metric. The batch format allows for the
## production of batch output formats and may more efficiently encode and write metrics.
# use_batch_format = false
## Data format to output.
## 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_OUTPUT.md
data_format = "influx"
## Jetstream specific configuration. If not nil, it will assume Jetstream context.
## Since this is a table, it should be present at the end of the plugin section. Else you can use inline table format.
# [outputs.nats.jetstream]
## Name of the stream, required when using jetstream.
# name = ""
## List of subjects to register on the stream
# subjects = []
## Use asynchronous publishing for higher throughput, but note that it does not guarantee order within batches.
# async_publish = false
## Timeout for wating on acknowledgement on asynchronous publishing
## String with valid units "ns", "us" (or "µs"), "ms", "s", "m", "h".
# async_ack_timeout = "5s"
## Full jetstream create stream config, refer: https://docs.nats.io/nats-concepts/jetstream/streams
# retention = "limits"
# max_consumers = -1
# max_msgs_per_subject = -1
# max_msgs = -1
# max_bytes = -1
# max_age = 0
# max_msg_size = -1
# storage = "file"
# discard = "old"
# num_replicas = 1
# duplicate_window = 120000000000
# sealed = false
# deny_delete = false
# deny_purge = false
# allow_rollup_hdrs = false
# allow_direct = true
# mirror_direct = false
## Disable creating the stream but assume the stream is managed externally
## and already exists. This will make the plugin fail if the steam does not exist.
# disable_stream_creation = falseSubject 配置
subject 设置决定了生产者消息将在 NATS 中发布到何处。这可以是一个静态主题 (例如,“telegraf”),或者一个使用 Go 的 text/template 语法的动态主题模板。
动态模板允许您根据每个指标的属性(例如标签、名称和字段)来构建主题。这使得在 NATS 或 JetStream 订阅者之间进行精细的路由和过滤成为可能。
此功能与 use_batch_format 不兼容
示例
基于标签和指标名称的路由
subject = '{{ .Tag "region" }}.{{ .Tag "datacenter" }}.{{ .Tag "host" }}.{{ .Name }}'基于标签、指标名称和字段名称的路由
subject = 'telegraf.metrics.{{ .Tag "datacenter" }}.{{ .Tag "host" }}.{{ .Name }}.{{ .Field "Value1" }}'如果您正在使用 JetStream,subject 的值将决定消息发布到何处。
使用动态主题模板时,Telegraf 不会自动将生成的 subject 注册到 JetStream stream。
对于动态 subject,您必须在 outputs.nats.jetstream.subjects 中显式定义匹配的 subject,以确保您的 stream 能够正确接收和保留这些消息。
此页面是否有帮助?
感谢您的反馈!
支持和反馈
感谢您成为我们社区的一员!我们欢迎并鼓励您对 Telegraf 和本文档提出反馈和 bug 报告。要获取支持,请使用以下资源
具有年度合同或支持合同的客户可以 联系 InfluxData 支持。