Parsing an array from mqtt topic

I have a go-eCharger that can be managed also with MQTT.
Two of the topics it send are arrays such as:

go-eCharger/201397/nrg = [233.74,2.48,3.41,1.24,0,0,0,0,0,0,0,0,0,0,0,0]
go-eCharger/201397/tma = [35.5,30.5]

No I am able to parse the fields in new keys t1 and t2 with:

  [[inputs.mqtt_consumer.topic_parsing]]
    topic = "go-eCharger/+/+"
    measurement = "measurement/_/_"
    tags = "_/chargerid/field"

  [[processors.regex]]
    [[processors.regex.fields]]
      key = "value"
      pattern = '^\[(\d+\.?\d*),(\d+\.?\d*)\]$'
      replacement = "${1}"
      result_key = "t1"

    [[processors.regex.fields]]
      key = "value"
      pattern = '^\[(\d+\.?\d*),(\d+\.?\d*)\]$'
      replacement = "${2}"
      result_key = "t2"

  [[processors.converter]]
    [processors.converter.fields]
      float = ["t1", "t2"]

However that result the new values to be strings, when running telegraf --test for the configuration.

> go-eCharger,chargerid=201397,host=pi.oh2th.fi t1="35.5",t2="30",tma="[35.5,30]" 1663598657338594386

How can I make sure that the result_keys would be float? Even with the converter but that does not change anything for the result.

I would immediately going to suggest the converter. Did you set an order to your processors when you used that? Was there some sort of error message that showed up?

Found the bug in the configuration:
key = "value"
should have of course been
key = "tma"

1 Like