<p>I have a Kuberenetes cluster and telegraf is running on each node. Telegraf is collecting data and storing into InfluxDB. Now I want to run another instance of telegraf which will use one of the pods namespace and collect stats from Apache server running inside the pod and store the stats in the same InfluxDB storage.</p>

<p>I followed this link (<a href="https://community.influxdata.com/t/multiple-telegraf-configs/245/6" rel="nofollow noreferrer">https://community.influxdata.com/t/multiple-telegraf-configs/245/6</a>) but couldn't figure out how can I implement this in my setup.</p>

<p>I am using <strong>Debian GNU/Linux 9 (stretch)</strong> and <strong>telegraf_1.12.5-1</strong>.</p>

<p>I created two service file as follows:</p>

<pre><code>cat /usr/lib/telegraf/scripts/telegraf.service
[Unit]
Description=The plugin-driven server agent for reporting metrics into InfluxDB
Documentation=https://github.com/influxdata/telegraf
After=network.target

[Service]
EnvironmentFile=-/etc/default/telegraf
User=telegraf
ExecStart=/usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d $TELEGRAF_OPTS
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
RestartForceExitStatus=SIGPIPE
KillMode=control-group

[Install]
WantedBy=multi-user.target
</code></pre>

<pre><code>cat /usr/lib/telegraf/scripts/telegraf_xyz.service
[Unit]
Description=The plugin-driven server agent for reporting metrics into InfluxDB
Documentation=https://github.com/influxdata/telegraf
After=network.target

[Service]
EnvironmentFile=-/etc/default/telegraf_xyz
User=telegraf
ExecStart=/usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d $TELEGRAF_OPTS
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
RestartForceExitStatus=SIGPIPE
KillMode=control-group

[Install]
WantedBy=multi-user.target
</code></pre>

<p>But when I try to run the second instance it's giving error:</p>

<pre><code>Failed to start telegraf_xyz.service: Unit telegraf_xyz.service not found.
</code></pre>

<p>What else changes I need to do as part of this? I see the telegraf.service file in many other locations (/sys/), I am not sure where else I need to configure the second telegraf instance. I am very new in this.</p>

<p>Is there any other better way to implement this in my setup?</p>

<p>NOTE: I have created two service file and able run that in my host. Now the real challange is running the instance in another net namespace. Can anyone help me to implement this?</p>

Soumyajit
<p>Please put your service file here: /etc/systemd/system/. Then reload systemd with systemctl daemon-reload. Your service should now be found.</p>
