Telegraf 可以将不同的数据来源(输入)写入多个不同的 InfluxDB 服务器(输出),或者单个 InfluxDB 的不同 bucket/表 写入数据。这基于Metric Filtering。
这个操作使用的是 Metric Filtering的 Selectors 功能,其中包括
-
namepass
-
namedrop
-
tagpass
-
["",""]
而在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
2条评论. Leave new
突然搜到你的这个论坛,然后意外的点了下友情链接,发现个新大陆,好多大佬,,,膜拜一下。学习学习
另外,为何你的一个小伙伴说你只是一个分区呢?
“Encrypting File System”