Multiple telegraf configs

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.

1 Like

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

Hey by the way! :wave:

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.

@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!

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

You would need to run multiple telegraf processes:

$ 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:

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

Does that help?


Thanks Jack. Let me test it.

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

1 Like

Yes you would need to create those service files

Where is the existing service file for telegraf?

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

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.


Glad you got it working!

@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?


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 to split the output data. Here is an example of splitting the data based on measurement name.

1 Like

Thank you for the reply daniel. we’ve applicated the tagpass filtering. however imo this solution would be the best suit to address this requirement.


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

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

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?

@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 ?

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.

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.