Skip to content

[MQTT topic parsing] Line Protocol elements should each be optional #10207

@samhld

Description

@samhld

Relevent telegraf.conf

[[inputs.mqtt_consumer]]
    servers = ["tcp://localhost:1883"]
    topics = ["sensors/#"]
    data_format = "value"
    data_type = "string"
    [[inputs.mqtt_consumer.topic_parsing]]
        topic = "sensors/+"
        measurement = "measurement/_/"
        tags = "_/sensor_id"

System info

Telegraf 1.21.0 rc0

Docker

No response

Steps to reproduce

See config above

Consider this case:
topic: sensors/0011
message: 45.0

I want Line Protocol like: sensors,sensor_id=0011 value=45.0

Pub to topic: sensors/0011 with message: 45.0

I would configure: measurement = "measurement/_" and tags = "_/sensor_id" and leave fields alone.

Expected behavior

Payloads may contain the necessary missing information for valid Line Protocol so there would be no need to address it in the topic. Or field information is just not required if the user is okay with a value=<value> type of field.

Actual behavior

The topic parsing configuration currently requires that measurement, tags, and fields params all be set and all underscores (i.e. _/_/_) does not circumvent this. A common use case for topic parsing is going to be to add the parsed information to an existing payload.

Additional info

No response

Metadata

Metadata

Assignees

Labels

area/mqttbugunexpected problem or unintended behavior

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions