Envió de datos de influxdb y publicarlo en MQTT

Hello

I am a beginner in influxdb and I am trying to send data that I have in a bucket to an MQTT, I have tried with telegraf and it did not work, so I am trying with the experimental function of mqtt.publish but I get an 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

Este es mi codigo

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”,
),
}),
)

I would be very grateful if you could tell me what other way there is to send this information.

Hello @fabianMol,
You can use the mqtt.to() function:

Have you tried that?

Yes, I already tried it and it didn’t work, in a forum I read that these functions were broken

Hello @fabianMol,
It should still work. The docs show functionality in InfluxDB 2.7.