Telegraf on IoT collecting metrics, outputting to Telegraf on Server?

Following on from this post, I’m running Telegraf on each of my IoT devices alongside a sensor-data-collection container, and having them post their data back to Influx, using this example as a guide.

I’ve now modified the IoT devices so that their sensor data goes to Telegraf on my server, rather than Influx directly. However, the Telegraf instances on the IoT devices are sending their data directly to Influx.

I was wondering, is it possible (and a good idea) to have the Telegraf instances on the IoT devices also output to Telegraf or https post, rather than using the Influxdb output?

Hi @mmcd,

I was wondering, is it possible (and a good idea) to have the Telegraf instances on the IoT devices also output to Telegraf

to forwarding data from a Telegraf to another, you have to rely on the socket_writer output plugin on the source (your IoT device) and the socket_listener input plugin on your receiving Telegraf host.

The socket_writer plugin support three output formats:

  1. InfluxDB Line Protocol
  2. JSON
  3. Graphite

All of those are supported by the socket_listener, so on the target you’ll receive data you can resent (via another output) wherever you need.

The only doubt I have regards the fact you’re talking about IoT devices: if you collect and send datas too frequently, having an IoT device that continuously convert data formats can be pretty heavy, but if you already send data to an InfluxDB, some kind of conversions already happens so I can suppose your device can manage it.

… or https post

There aren’t any http(s) specific outputs, so you can’t easily solve this. The only things come to my mind it’s using the InfluxDB output as a sort of https POST output. With that output basically data was passed to InfluxDB via an http(s) POST.
You can reimplement the InfluxDB APIs on your http(s) receiver, but I think can be a lot of effort, easly avoided using a real InfluxDB receiver and some kind of application which read and convert data in your required format.

Br.

You can use the influxdb output to send to the http_listener input since this input operates as a stand-in for InfluxDB’s HTTP service.

I would also probably send the metrics from the IoT Telegraf to the server-side Telegraf, this way all metrics follow the same route and it gives maximum benefit from batching requests to InfluxDB.

I’m not sure how feasible it is, but it may also make sense for the IoT Telegraf to gather/receive all metrics on the device, including from the sensor-data-container, and be the only connection to your servers for metrics.

Thank you both, I’ll have a go at setting this up over the weekend and report back.

After a break I have tried to get this working. However, basic on my server I use different endpoints to redirect the incoming metric to different http_listeners, when I do the write I need to send it to https://myserver.com/write/myendpoint.
It seems though that the /myendpoint part is ignored, and data is always sent to /write (whether that is included or not in the output plugin url definition).
Wondered if anyone else could confirm if I’m correct on this and if so whether there’s a workaround?

The influxdb output always writes the /write resource, although you can add a prefix to the path: urls = ["http://127.0.0.1:8086/foo"] will write to /foo/write.

In the upcoming 1.7 release you can try the http output which can write to any path but doesn’t include any InfluxDB specific options like database or retention policy.

That’s great, thank you.