0

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

4
  • In your code, you need to make changes specifically to the line where you're specifying the MQTT password. Here's the line that needs to be corrected. password: 02342321223113", You should add a quotation mark (") at the beginning of the password string, This should resolve the syntax error you encountered.
    – user9416106
    Commented Mar 11 at 14:55
  • Performing the correction the same error still appears.
    – FaMolano
    Commented Mar 11 at 15:49
  • This issue may be of interest.
    – Brits
    Commented Mar 11 at 18:53
  • @FaMolano extra comma should be removed: username: "publicador"
    – user9416106
    Commented Mar 13 at 10:40

1 Answer 1

0

Only supported in InfluxDB Cloud (TSM)

The experimental/mqtt package only supported in InfluxDB Cloud (TSM). It is still available to import in InfluxDB OSS and Enterprise, but functions will not successfully publish to an MQTT broker.

https://docs.influxdata.com/flux/v0/stdlib/experimental/mqtt/publish/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.