I have a Telegraf configuration that gets input data from different Modbus devices using Input Modbus plugin and stores that data into InfluxDB using InfluxDB output plugin.
Is it possible to send specific metrics to InfluxDB when Modbus devices are returning errors?
For example, I have the following configuration:
[[inputs.modbus]]
interval = “5s”
name_override=“ModbusDevice”
tagexclude = [“type”, “name”, “host”, “slave_id”]
name = “NOT USED”
slave_id = 0
timeout = “3s”
controller = “tcp://192.168.50.20:502”
holding_registers = [
{ name = “Item1”, byte_order = “ABCD”, data_type = “FIXED”, scale=0.001, address = [30121,30122]},
{ name = “Item2”, byte_order = “ABCD”, data_type = “FIXED”, scale=0.001, address = [30125,30126]},
]
[inputs.modbus.tags]
plant = “Test Plant”
device=“Test Device”
When Modbus devices are not responding, I see the following rows in .log file:
2024-01-03T20:09:54Z E! [inputs.modbus] Error in plugin: dial tcp 192.168.50.20:502: i/o timeout
2024-01-03T20:09:59Z E! [inputs.modbus] Error in plugin: dial tcp 192.168.50.20:502: i/o timeout
I would like to have the information in InfluxDB that this particular metric is not available now due to i/o timeout, i.e. to send metric that has failing controller in config file (i.e. 192.168.50.20:502 in this example) with all configured tags and just one special field (i.e. error) with error message. The same approach is expected for all other possible errors (i.e. Illegal data value etc.).
How to achieve that?
I have seen this feature request, but it is still open and no solution is suggested…
Here use case that I need is also described…