I’m not sure why you need to change your setup if it works, but I would switch to the xpath_json
parser instead of using the more complex json_v2
one:
[[inputs.mqtt_consumer]]
servers = ["tcp://127.0.0.1:1883"]
topics = [
# Real topic structure
# "home/OpenMQTTGateway_lilygo_rtl_433_ESP/RTL_433toMQTT/Bresser-3CH/1/130",
"home/OpenMQTTGateway_lilygo_rtl_433_ESP/RTL_433toMQTT/#"
]
topic_tag = "topic"
qos = 0
username = "telegraf"
password = "notmyrealpassword"
data_format = "xpath_json"
xpath_native_types = true
[[inputs.mqtt_consumer.topic_parsing]]
topic = "+/+/+/+/+/+"
tags = "site/_/_/model/channel/device_id"
[[inputs.mqtt_consumer.xpath]]
metric_name = "'mymetric'"
[inputs.mqtt_consumer.xpath.fields]
battery_ok = "/battery_ok = 1"
temperature = "/temperature_C"
humidity = "/humidity"
rssi = "/rssi"
[inputs.mqtt_consumer.xpath.tags]
channel = "/channel"
id = "/id"
model = "/model"
which produces
> mymetric,channel=1,host=Hugin,id=130,model=Bresser-3CH battery_ok=true,humidity=19,rssi=-61,temperature=12.66667 1728307076000000000
for your example…
Regarding topic-parsing: You can leave this out if you don’t need the tags defined there…