Telegraf 多输入多输出

Telegraf 多输入多输出

Telegraf 可以将不同的数据来源(输入)写入多个不同的 InfluxDB 服务器(输出),或者单个 InfluxDB 的不同 bucket/表 写入数据。这基于Metric Filtering。

这个操作使用的是 Metric Filtering的 Selectors 功能,其中包括

  • namepass

  • namedrop

  • tagpass

  • tagdrop

name针对measurement的名称,而tag对应标签。pass是白名单,drop是黑名单,他们都是以["",""]的形式存在。它的关系是或,只要满足一条即可。

而在input插件中使用

  • name_override 覆盖 measurement 名称

  • name_prefix 加上前缀

  • name_suffix 加上后缀

  • tags 加上标签

比如加上 prefix “win_” 那么 measurement “cpu” 就会变成 “win_cpu”,在 namepass/namedrop 中就可以使用 “win_*” 过滤。下面是一个实际的例子。


[[outputs.influxdb_v2]]
   urls = ["http://127.0.0.1:8086"]
   token = ""
   organization = "demo"
   bucket = "device_a"
   namepass= ["devicea_*"]
[[outputs.influxdb_v2]]
   urls = ["http://127.0.0.1:8086"]
   token = ""
   organization = "demo
   bucket = "device_b"
   namepass= ["deviceb_*"]
[[inputs.modbus]]
  name_prefix = "devicea_"
  name = "Kompressor 1"
  slave_id = 1
  timeout = "1s"
  controller = "tcp://172.16.0.11:502"
  holding_registers = [
    { name = "Total Leistung", byte_order = "ABCD",   data_type = "FLOAT32-IEEE", scale=1.0,  address = [121,122]},
    { name = "L1 Leistung", byte_order = "ABCD",   data_type = "FLOAT32-IEEE", scale=1.0,  address = [35,36]},
    { name = "L2 Leistung", byte_order = "ABCD",   data_type = "FLOAT32-IEEE", scale=1.0,  address = [37,38]},
    { name = "L3 Leistung", byte_order = "ABCD",   data_type = "FLOAT32-IEEE", scale=1.0,  address = [39,40]},
    { name = "Temperatur", byte_order = "ABCD",   data_type = "FLOAT32-IEEE", scale=1.0,  address = [73,74]},
  ]
[[inputs.modbus]]
  name_prefix = "deviceb_"
  name = "Kompressor 2"
  slave_id = 1
  timeout = "1s"
  controller = "tcp://172.16.0.12:502"
  holding_registers = [
    { name = "Total Leistung", byte_order = "ABCD",   data_type = "FLOAT32-IEEE", scale=1.0,  address = [121,122]},
    { name = "L1 Leistung", byte_order = "ABCD",   data_type = "FLOAT32-IEEE", scale=1.0,  address = [35,36]},
    { name = "L2 Leistung", byte_order = "ABCD",   data_type = "FLOAT32-IEEE", scale=1.0,  address = [37,38]},
    { name = "L3 Leistung", byte_order = "ABCD",   data_type = "FLOAT32-IEEE", scale=1.0,  address = [39,40]},
    { name = "Temperatur", byte_order = "ABCD",   data_type = "FLOAT32-IEEE", scale=1.0,  address = [73,74]},
  ]

在这个例子中,分别将 Kompressor 1/2 存储到 device_a 和 device_b 中。

参考文档:

https://github.com/influxdata/telegraf/blob/master/docs/CONFIGURATION.md#metric-filtering

https://stackoverflow.com/questions/57896950/configure-multiple-output-plugins-with-telegraf

Amefs, EFS, InfluxDB, IT, Linux
上一篇文章
钢之炼金术师 FA BDRip 制作的碎碎念
下一篇文章
Grafana 集成 HWinfo 监控

2条评论. Leave new

  • 突然搜到你的这个论坛,然后意外的点了下友情链接,发现个新大陆,好多大佬,,,膜拜一下。学习学习
    另外,为何你的一个小伙伴说你只是一个分区呢?

    回复

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

Fill out this field
Fill out this field
请输入有效的邮箱地址。

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据

keyboard_arrow_up