Hi everyone,
i am faced with the problem that in my telegraf.conf the processors (regex & enum) are not executed when the [[inputs.mqtt_consumer.topic_parsing]] is used! With out this table it works fine. Beside the fact, that the measurement name is part of the topic.
I did not get any error message in the logs. I’m running telegraf in docker.
Tryed versions:
- 1.33.2 - 1.33-alpine
- 1.32 - 1.32-alpine
- 1.28.5
Question: Is there any reason for that behavior?
[agent]
round_interval = true
metric_batch_size = 10
metric_buffer_limit = 10000
collection_jitter = "1s"
flush_interval = "10s"
flush_jitter = "0s"
debug = true
omit_hostname = true
[[inputs.mqtt_consumer]]
servers = ["$MQTT_BROKER_URL"]
topics = ["xxx/+/DDATA"]
topic_tag=""
qos = 0
client_id = ""
username = "$MQTT_BROKER_USERNAME"
password = "$MQTT_BROKER_PASSWORD"
data_format = "json_v2"
### when uncommenting this part, processors are not executed anymore.
# [[inputs.mqtt_consumer.topic_parsing]]
# topic = "xxx/+/DDATA"
# measurement = "_/measurement/_"
[[inputs.mqtt_consumer.json_v2]]
timestamp_path = "timestamp"
timestamp_format = "unix_ms"
[[inputs.mqtt_consumer.json_v2.object]]
path = 'metrics.#(type==9)#'
optional = true
tags = ['type', 'name', 'unit']
excluded_keys = ['alias','timestamp']
[inputs.mqtt_consumer.json_v2.object.renames]
name = 'key'
[inputs.mqtt_consumer.json_v2.object.fields]
value = 'float'
[[inputs.mqtt_consumer.json_v2.object]]
path = 'metrics.#(type==12)#'
optional = true
tags = ['type', 'name', 'unit']
excluded_keys = ['alias','timestamp']
[inputs.mqtt_consumer.json_v2.object.renames]
name = 'key'
[inputs.mqtt_consumer.json_v2.object.fields]
value = 'string'
[[inputs.mqtt_consumer.json_v2.object]]
path = 'metrics.#(type==3)#'
optional = true
tags = ['type', 'name', 'unit']
excluded_keys = ['alias','timestamp']
[inputs.mqtt_consumer.json_v2.object.renames]
name = 'key'
[inputs.mqtt_consumer.json_v2.object.fields]
value = 'int'
[[processors.enum]]
namepass = ["mqtt_consumer"]
[[processors.enum.mapping]]
tag = "type"
[processors.enum.mapping.value_mappings]
"9" = "float"
"3" = "int"
"12" = "string"
[[processors.regex]]
namepass = ["mqtt_consumer"]
[[processors.regex.tags]]
key = "key"
pattern = "^.*/(.*)"
replacement = "$1"
[[outputs.mqtt]]
servers = ["$MQTT_BROKER_URL"]
topic = "telegraf"
data_format = "influx"
Here are the input payload:
{
"metrics": [
{
"alias": 61,
"value": 56.30668139550835,
"name": "telemetry/sinosodial",
"timestamp": 1739518863391,
"unit": "V",
"type": 9
},
{
"alias": 62,
"value": 7284,
"name": "telemetry/sawtooth",
"timestamp": 1739518863391,
"unit": "",
"type": 3
},
{
"alias": 63,
"value": "crocodilia",
"name": "telemetry/status",
"timestamp": 1739518863391,
"unit": "",
"type": 12
}
],
"seq": 81,
"timestamp": 1739518863391
}