Hi there,
this undoubtedly is a beginners question but I keep looking, trying etc. without any success. I have an application that can send its measurements via MQTT. Every app. 10 seconds I receive a bunch of measurements like this:
solaranzeige/pv-garage/ac_ausgangsfrequenz 49.986938476562
solaranzeige/pv-garage/solarspannung_string_2 298.82556152344
solaranzeige/pv-garage/solarstrom_string_2 0.98286706209183
solaranzeige/pv-garage/ac_wirkleistung 526.43493652344
I would love to translate this to an influx measurement pv-garage with
timestamp, ac_ausgangsfrequenz, solarspannung_string_2, solarstrom_string_2, ac_wirkleistung
When I use
[[inputs.mqtt_consumer]]
## Topics that will be subscribed to.
### MQTT server data...
topics = [
"solaranzeige/#",
]
data_format="value"
data_type="float"
[[inputs.mqtt_consumer.topic_parsing]]
topic = "solaranzeige/+/+"
measurement = "_/measurement/_"
tags = "_/_/field"
I get
pv-garage,field=ac_ausgangsfrequenz,host=analysis,topic=solaranzeige/pv-garage/ac_ausgangsfrequenz value=49.97631072998 1678718599895328449
pv-garage,field=solarspannung_string_2,host=analysis,topic=solaranzeige/pv-garage/solarspannung_string_2 value=277.36282348633 1678718599895343882
pv-garage,field=solarstrom_string_2,host=analysis,topic=solaranzeige/pv-garage/solarstrom_string_2 value=0.37698721885681 1678718599895359030
pv-garage,field=ac_wirkleistung,host=analysis,topic=solaranzeige/pv-garage/ac_wirkleistung value=172.58512878418 1678718599895385720
First question: How do I get rid of the “host” tag as I do not need it and where does it come from in the first place? Then I do not really need the topic tag in the output. Esp. since this then breaks pivoting. I tried
[[processors.pivot]]
tag_key = "field"
value_key = "value"
which brings me to:
pv-garage,host=analysis,topic=solaranzeige/pv-garage/ac_ausgangsfrequenz ac_ausgangsfrequenz=49.994220733643 1678718789339766130
pv-garage,host=analysis,topic=solaranzeige/pv-garage/solarspannung_string_2 solarspannung_string_2=282.73272705078 1678718789339772460
pv-garage,host=analysis,topic=solaranzeige/pv-garage/solarstrom_string_2 solarstrom_string_2=0.42668148875237 1678718789339779801
pv-garage,host=analysis,topic=solaranzeige/pv-garage/ac_wirkleistung ac_wirkleistung=180.20916748047 1678718789339838840
I would have expected one line with the four fields columns. The first problem is the changing topic (which I wanted to get rid of in the first place). The second is the timestamp since the MQTT datagrams are processed at a different time. The last problem I could maybe work around with an aggregator function and a suitable period. But I still will not get everything into one line. I must be missing something obvious but what?
Any help would be greatly appreciated.