# Multiple telegraf configs

**URL:** <https://community.influxdata.com/t/multiple-telegraf-configs/245>\
**Category:** Systems\
**Created:** [March 15, 2017, 5:36pm UTC](https://community.influxdata.com/t/multiple-telegraf-configs/245 "2017-03-15T17:36:18Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![errishma](https://avatars.discourse-cdn.com/v4/letter/e/f07891/32.png) [@errishma](https://community.influxdata.com/u/errishma)\
**Post date:** [March 15, 2017, 5:36pm UTC](https://community.influxdata.com/t/multiple-telegraf-configs/245/1 "2017-03-15T17:36:18Z")

</div>

I am running one base config in /etc/telegraf/telegraf.conf and one customized config in /etc/telegraf/telegraf.d . I want to send data to different influx servers designated to each config.

The result I am seeing is data is being duplicated in both the servers. Please guide how to resolve this.

---

<div class="post-metadata">

**Author:** ![jackzampolin](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/jackzampolin/32/5_2.png) [@jackzampolin](https://community.influxdata.com/u/jackzampolin)\
**Post date:** [March 15, 2017, 6:33pm UTC](https://community.influxdata.com/t/multiple-telegraf-configs/245/2 "2017-03-15T18:33:15Z")

</div>

@errishma Are you running two copies of the `telegraf` daemon? Is the desired result that data is duplicated?

Hey by the way! 👋

---

<div class="post-metadata">

**Author:** ![errishma](https://avatars.discourse-cdn.com/v4/letter/e/f07891/32.png) [@errishma](https://community.influxdata.com/u/errishma)\
**Post date:** [March 15, 2017, 6:35pm UTC](https://community.influxdata.com/t/multiple-telegraf-configs/245/3 "2017-03-15T18:35:07Z")

</div>

Hi Jack.  
Good to hear from you. How are you?  
We have one telegraf daemon and two configs Desired result is that data should not be duplicated.

---

<div class="post-metadata">

**Author:** ![jackzampolin](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/jackzampolin/32/5_2.png) [@jackzampolin](https://community.influxdata.com/u/jackzampolin)\
**Post date:** [March 15, 2017, 6:53pm UTC](https://community.influxdata.com/t/multiple-telegraf-configs/245/4 "2017-03-15T18:53:40Z")

</div>

@errishma To run both of the configs you would need to run 2 telegraf daemons. For zero data duplication the two configurations would need to not contain any of the same plugins and each would write to a separate influxdb instance.

I’m great! Enjoying the nice weather down here!

---

<div class="post-metadata">

**Author:** ![errishma](https://avatars.discourse-cdn.com/v4/letter/e/f07891/32.png) [@errishma](https://community.influxdata.com/u/errishma)\
**Post date:** [March 15, 2017, 6:54pm UTC](https://community.influxdata.com/t/multiple-telegraf-configs/245/5 "2017-03-15T18:54:46Z")

</div>

Thanks Jack. How to create multiple Daemon. Please guide.

---

<div class="post-metadata">

**Author:** ![jackzampolin](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/jackzampolin/32/5_2.png) [@jackzampolin](https://community.influxdata.com/u/jackzampolin)\
**Post date:** [March 15, 2017, 7:12pm UTC](https://community.influxdata.com/t/multiple-telegraf-configs/245/6 "2017-03-15T19:12:53Z")

</div>

You would need to run multiple `telegraf` processes:

```auto
$ telegraf -config config1 > telegraf1.log 2>&1 &
$ telegraf -config config2 > telegraf2.log 2>&1 &

```

If you need `systemd` or `init.d` to keep the process alive and start on boot then you would need to copy the service file and change some naming so that you could run:

```auto
$ sudo systemctl start telegraf1
$ sudo systemctl start telegraf2
# OR
$ sudo service telegraf1 start
$ sudo service telegraf2 start

```

Does that help?

Jack

---

<div class="post-metadata">

**Author:** ![errishma](https://avatars.discourse-cdn.com/v4/letter/e/f07891/32.png) [@errishma](https://community.influxdata.com/u/errishma)\
**Post date:** [March 15, 2017, 7:28pm UTC](https://community.influxdata.com/t/multiple-telegraf-configs/245/7 "2017-03-15T19:28:34Z")

</div>

Thanks Jack. Let me test it.

Do we need to create the service like telegraf1 or telegraf2 when systemctl or service is run ?

---

<div class="post-metadata">

**Author:** ![jackzampolin](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/jackzampolin/32/5_2.png) [@jackzampolin](https://community.influxdata.com/u/jackzampolin)\
**Post date:** [March 15, 2017, 8:03pm UTC](https://community.influxdata.com/t/multiple-telegraf-configs/245/8 "2017-03-15T20:03:49Z")

</div>

Yes you would need to create those service files

---

<div class="post-metadata">

**Author:** ![errishma](https://avatars.discourse-cdn.com/v4/letter/e/f07891/32.png) [@errishma](https://community.influxdata.com/u/errishma)\
**Post date:** [March 15, 2017, 8:05pm UTC](https://community.influxdata.com/t/multiple-telegraf-configs/245/9 "2017-03-15T20:05:35Z")

</div>

Where is the existing service file for telegraf?

---

<div class="post-metadata">

**Author:** ![errishma](https://avatars.discourse-cdn.com/v4/letter/e/f07891/32.png) [@errishma](https://community.influxdata.com/u/errishma)\
**Post date:** [March 15, 2017, 9:35pm UTC](https://community.influxdata.com/t/multiple-telegraf-configs/245/10 "2017-03-15T21:35:19Z")

</div>

I think I got it. Please let me know if the approach is wrong.

I created one service telegraf1.service and changed the file to

[Service]  
EnvironmentFile=-/etc/default/telegraf1  
User=telegraf  
Environment='STDOUT=/var/log/telegraf/telegraf1.log’  
Environment='STDERR=/var/log/telegraf/telegraf1.log’  
ExecStart=/bin/sh -c “exec /usr/bin/telegraf -config /etc/telegraf/telegraf.d/telegraf.conf -config-directory /etc/telegraf/telegraf.d ${TELEGRAF\_OPTS} \>\>${STDOUT} 2\>\>${STDERR}”

and then ran the command  
service telegraf1 start

I see the data going to telegraf1 database in expected server and not duplicated. I will test more on this and let you know if any further issues.

Thank you Jack.  
~

---

<div class="post-metadata">

**Author:** ![jackzampolin](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/jackzampolin/32/5_2.png) [@jackzampolin](https://community.influxdata.com/u/jackzampolin)\
**Post date:** [March 15, 2017, 10:59pm UTC](https://community.influxdata.com/t/multiple-telegraf-configs/245/11 "2017-03-15T22:59:36Z")

</div>

Glad you got it working!

---

<div class="post-metadata">

**Author:** ![ru87](https://avatars.discourse-cdn.com/v4/letter/r/9fc348/32.png) [@ru87](https://community.influxdata.com/u/ru87)\
**Post date:** [November 30, 2018, 6:30pm UTC](https://community.influxdata.com/t/multiple-telegraf-configs/245/12 "2018-11-30T18:30:51Z")

</div>

@errishma, @jackzampolin can you report exactly how you configure the double telegraf service?

I’m on a centos server and I see all my services at `/etc/init.d`, telegraf included.  
You report instead the content of the telegraf.service file that i locate at `/usr/lib/telegraf/scripts/telegraf.service`.

I’m a bit confused. What i would do is to copy and rename telegraf service under init.d directory and then modify config path to the second telegraf config file.

How telegraf.service file should be used instead?

thanks,  
Ruggiero

---

<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:** [November 30, 2018, 9:02pm UTC](https://community.influxdata.com/t/multiple-telegraf-configs/245/13 "2018-11-30T21:02:27Z")

</div>

It is almost never need required to run multiple Telegraf’s on a single system, including in the original use case of this thread. The proper way to set this up is to use [metric filtering](https://github.com/influxdata/telegraf/blob/master/docs/CONFIGURATION.md#metric-filtering) to split the output data. Here is [an example](https://github.com/influxdata/telegraf/blob/master/docs/CONFIGURATION.md#output-configuration-examples) of splitting the data based on measurement name.

---

<div class="post-metadata">

**Author:** ![ru87](https://avatars.discourse-cdn.com/v4/letter/r/9fc348/32.png) [@ru87](https://community.influxdata.com/u/ru87)\
**Post date:** [December 4, 2018, 10:43am UTC](https://community.influxdata.com/t/multiple-telegraf-configs/245/14 "2018-12-04T10:43:59Z")

</div>

Thank you for the reply daniel. we’ve applicated the tagpass filtering. however imo [this solution](https://github.com/influxdata/telegraf/issues/809#issuecomment-193595539) would be the best suit to address this requirement.

ruggiero

---

<div class="post-metadata">

**Author:** ![Sumit\_Sharma](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/sumit_sharma/32/3123_2.png) [@Sumit\_Sharma](https://community.influxdata.com/u/Sumit_Sharma)\
**Post date:** [June 4, 2019, 8:27am UTC](https://community.influxdata.com/t/multiple-telegraf-configs/245/16 "2019-06-04T08:27:09Z")

</div>

I have multiple telegraf. so my query is how to identify which metrics is comes form which telegraf. please guide me how to track.

---

<div class="post-metadata">

**Author:** ![MarcV](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/marcv/32/7676_2.png) [@MarcV](https://community.influxdata.com/u/MarcV)\
**Post date:** [June 4, 2019, 8:40am UTC](https://community.influxdata.com/t/multiple-telegraf-configs/245/17 "2019-06-04T08:40:26Z")

</div>

Hi @Sumit_Sharma , welcome !

If they are running on the same server You could use [global\_tags]  
Or change the hostname for each Telegraf config.

Hope this helps , best regards

---

<div class="post-metadata">

**Author:** ![Sumit\_Sharma](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/sumit_sharma/32/3123_2.png) [@Sumit\_Sharma](https://community.influxdata.com/u/Sumit_Sharma)\
**Post date:** [June 5, 2019, 12:40pm UTC](https://community.influxdata.com/t/multiple-telegraf-configs/245/18 "2019-06-05T12:40:30Z")

</div>

I have a microservice architecture so there are multiple instances for telegraf, which are sending data to one telegraf http input plugin. I need to identify the telegrafs for further processing. Can you please help me with this?

---

<div class="post-metadata">

**Author:** ![MarcV](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/marcv/32/7676_2.png) [@MarcV](https://community.influxdata.com/u/MarcV)\
**Post date:** [June 5, 2019, 2:09pm UTC](https://community.influxdata.com/t/multiple-telegraf-configs/245/19 "2019-06-05T14:09:00Z")

</div>

@Sumit_Sharma ,

the telegraf services can be started as follows

telegraf --config telegraf1.conf  
telegraf --config telegraf2.conf

you can set [global\_tags] in each configuration file to identify the telegraf service.

is this a good solution for you ?

---

<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:** [June 5, 2019, 6:31pm UTC](https://community.influxdata.com/t/multiple-telegraf-configs/245/20 "2019-06-05T18:31:28Z")

</div>

I generally discourage running multiple Telegraf instances on a single server/container. I won’t say you should never do it but its hardly ever needed. If you stick to this, the easiest way to know which Telegraf reported the metric is to use the `host` tag that Telegraf sends with all data by default.

---

<div class="post-metadata">

**Author:** ![Sumit\_Sharma](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/sumit_sharma/32/3123_2.png) [@Sumit\_Sharma](https://community.influxdata.com/u/Sumit_Sharma)\
**Post date:** [June 25, 2019, 4:54am UTC](https://community.influxdata.com/t/multiple-telegraf-configs/245/21 "2019-06-25T04:54:59Z")

</div>

My all data saved in InfluxDB, and I want to migrate or sent data to Prometheus, from the Influx database, so is there any way to migrate data or sent data to Prometheus. Please give me response it,s very urgent.

[Next page](https://community.influxdata.com/t/multiple-telegraf-configs/245.md?page=2)
