Skip to main content
Version: Next

MQTT

The MQTT output publishes each message to an MQTT broker topic. It supports QoS 0/1/2, clean sessions, keep-alive, retained messages, and optional username/password authentication.

Configuration

FieldTypeRequiredDefaultDescription
typestringyesFixed value "mqtt"
hoststringyesMQTT broker hostname.
portintegeryesMQTT broker port.
client_idstringyesClient identifier.
usernamestringnoUsername for authentication.
passwordstringnoPassword for authentication.
topicobjectyesDestination topic (expression; see below).
qosintegernoQuality of Service: 0, 1, or 2.
clean_sessionbooleannoWhether to use a clean session.
keep_aliveintegernoKeep-alive interval in seconds.
retainbooleannoWhether to retain the message on the broker.
value_fieldstringnoRecord field used as the message payload.

topic

topic is an Expr<String> object with one of these shapes:

FieldTypeRequiredDescription
typestringyesvalue (static) or expr (SQL expression).
valuestringyes (value)Static topic name.
exprstringyes (expr)SQL expression evaluated per message.

Examples

Static topic

output:
type: "mqtt"
host: "localhost"
port: 1883
client_id: "my-client"
username: "user"
password: "pass"
topic:
type: "value"
value: "my-topic"
qos: 2
clean_session: true
keep_alive: 60
retain: true
value_field: "message"

Dynamic topic via SQL expression

output:
type: "mqtt"
host: "localhost"
port: 1883
client_id: "sensor-client"
topic:
type: "expr"
expr: "concat('sensor/', id)"
qos: 1