How can I send data from influxdb to MQTT?

41 views Asked by At

I am new to influxdb and I am trying to send data from my bucket to an MQTT, I already tried it with telegraf but it didn't work, so I tried it with flux and I get the following error.

could not execute task run: runtime error @9:8-22:6: map: failed to evaluate map function: Dialer.Dial called on an error dependency

This is the code I am using


import "experimental/mqtt"

option task = {name: "EnvioDataToMqtt", every: 1m, offset: 0m}

 from(bucket: "recepcionDatos")
    |> range(start: -1h)
    |> filter(fn: (r) => r._measurement == "medida")
    |> filter(fn: (r) => r._field == "value")
    |> map(
        fn: (r) =>
            ({r with sent:
                    mqtt.publish(
                        broker: "tcp://miservidor:18083",
                        topic: "dataInflux/prueba",
                        message: string(v: r._value),
                        clientid: "mqttx",
                        password: "02342321223113",
                        qos: 0,
                        username: "publicador",
                    ),
            }),
    )

If you know of another way to send data from influxdb to MQTT, I appreciate your collaboration.

Find a way to send my influxdb data to MQTT

0

There are 0 answers