Configuration websocket url in telegraf output plugin

Hello,

I’m using this configuration :

  • sensors (python script) generating several (N) mqtt topics “vehicles/+/op_test”
  • telegraf inputs.mqtt_consumers
  • telegraf outputs.websocket
  • grafana data source (grafana : live measurements) accepting websocket

here is the telegraf conf file:

[[inputs.mqtt_consumer]]
servers = [“tcp://192.168.0.78:1883”]
topics = [“vehicles/+/op_test”]
data_format = “json_v2”
[[inputs.mqtt_consumer.json_v2]]
[[inputs.mqtt_consumer.json_v2.tag]]
path = “id”
[[inputs.mqtt_consumer.json_v2.field]]
path = “timestamp”
[[inputs.mqtt_consumer.json_v2.field]]
path = “speed”
[[inputs.mqtt_consumer.json_v2.field]]
path = “coord.latitude”
[[inputs.mqtt_consumer.json_v2.field]]
path = “coord.longitude”

[[outputs.websocket]]
url = “ws://192.168.0.78:3000/api/live/push/custom_stream”
data_format = “influx”
[outputs.websocket.headers]
Authorization = “Bearer xxx…xxx”

my problem is that I’m not able to differentiate vehicle at grafana level, I would like to get one different websocket url per vehicle like this:

[[outputs.websocket]]
url = “ws://192.168.0.78:3000/api/live/push/custom_stream/”+id

“id” would come from the “id” from the input tag.

thanks guys, have a good day.

Olivier
Is it feasible? I could not find a solution yet.

Hi,

If you are looking to dynamically create the URL based on input data, then to my knowledge Telegraf does not have that capability.

my problem is that I’m not able to differentiate vehicle at grafana level

It sounds like you are using Grafana’s streaming capability? Is grouping by the id in grafana not possible? Is it because it is numeric data?

Hello Jpowers, you understood my problem correctly, thanks. I’m new to grafana and I’m goign to check what grouping by the id is and I’ll come back, thanks, have a good day.