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

**URL:** <https://community.influxdata.com/t/telegraf-on-iot-collecting-metrics-outputting-to-telegraf-on-server/5106>\
**Category:** Systems\
**Tags:** influxdb, telegraf\
**Created:** [May 10, 2018, 7:30am UTC](https://community.influxdata.com/t/telegraf-on-iot-collecting-metrics-outputting-to-telegraf-on-server/5106 "2018-05-10T07:30:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mmcd](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@mmcd](https://community.influxdata.com/u/mmcd)\
**Post date:** [May 10, 2018, 7:30am UTC](https://community.influxdata.com/t/telegraf-on-iot-collecting-metrics-outputting-to-telegraf-on-server/5106/1 "2018-05-10T07:30:29Z")

</div>

Following on from [this](https://community.influxdata.com/t/http-listener-in-telegraf-data-security/5069) 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](https://resin.io/blog/add-a-metrics-monitoring-service-to-your-resin-io-multicontainer-application/) 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?

---

<div class="post-metadata">

**Author:** ![mcappadonna](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/mcappadonna/32/2004_2.png) [@mcappadonna](https://community.influxdata.com/u/mcappadonna)\
**Post date:** [May 10, 2018, 10:12am UTC](https://community.influxdata.com/t/telegraf-on-iot-collecting-metrics-outputting-to-telegraf-on-server/5106/2 "2018-05-10T10:12:32Z")

</div>

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](https://github.com/influxdata/telegraf/tree/master/plugins/outputs/socket_writer) output plugin on the source (your IoT device) and the [socket\_listener](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/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.

---

<div class="post-metadata">

**Author:** ![daniel](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/daniel/32/142_2.png) [@daniel](https://community.influxdata.com/u/daniel)\
**Post date:** [May 10, 2018, 11:38pm UTC](https://community.influxdata.com/t/telegraf-on-iot-collecting-metrics-outputting-to-telegraf-on-server/5106/3 "2018-05-10T23:38:03Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mmcd](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@mmcd](https://community.influxdata.com/u/mmcd)\
**Post date:** [May 11, 2018, 4:05pm UTC](https://community.influxdata.com/t/telegraf-on-iot-collecting-metrics-outputting-to-telegraf-on-server/5106/4 "2018-05-11T16:05:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mmcd](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@mmcd](https://community.influxdata.com/u/mmcd)\
**Post date:** [May 22, 2018, 4:31pm UTC](https://community.influxdata.com/t/telegraf-on-iot-collecting-metrics-outputting-to-telegraf-on-server/5106/5 "2018-05-22T16:31:05Z")

</div>

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](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?

---

<div class="post-metadata">

**Author:** ![daniel](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/daniel/32/142_2.png) [@daniel](https://community.influxdata.com/u/daniel)\
**Post date:** [May 22, 2018, 5:57pm UTC](https://community.influxdata.com/t/telegraf-on-iot-collecting-metrics-outputting-to-telegraf-on-server/5106/6 "2018-05-22T17:57:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mmcd](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@mmcd](https://community.influxdata.com/u/mmcd)\
**Post date:** [May 23, 2018, 12:09pm UTC](https://community.influxdata.com/t/telegraf-on-iot-collecting-metrics-outputting-to-telegraf-on-server/5106/7 "2018-05-23T12:09:37Z")

</div>

That’s great, thank you.
