Hello InfluxCommunity,
I am trying to get Telegraf to run as a service on my Ubuntu server. It seems to run okay from the path itself but when I start it from a service it fails.
Telegraf works when it is ran from path:
/home/user/telegraf/usr/bin/telegraf -config /home/user/telegraf/etc/telegraf/telegraf.conf -config-directory /home/user/telegraf/etc/telegraf/telegraf.d &
I tried editing the service file’s EXEC start path to above, it still fails to run as a service.
Any ideas?
Details of the telegraf service unit file
user@ubuntu-20:~$ cat /etc/systemd/system/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
systemctl status telegraf error:
user@ubuntu-20:~$ sudo systemctl status telegraf
● telegraf.service - The plugin-driven server agent for reporting metrics into InfluxDB
Loaded: loaded (/etc/systemd/system/telegraf.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2021-12-01 20:41:50 EST; 5min ago
Docs: https://github.com/influxdata/telegraf
Process: 256986 ExecStart=/usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d $TELEGRAF_OPTS (code=exited, status=217/USER)
Main PID: 256986 (code=exited, status=217/USER)
Dec 01 20:41:50 ubuntu-20 systemd[1]: telegraf.service: Scheduled restart job, restart counter is at 5.
Dec 01 20:41:50 ubuntu-20 systemd[1]: Stopped The plugin-driven server agent for reporting metrics into InfluxDB.
Dec 01 20:41:50 ubuntu-20 systemd[1]: telegraf.service: Start request repeated too quickly.
Dec 01 20:41:50 ubuntu-20 systemd[1]: telegraf.service: Failed with result 'exit-code'.
Dec 01 20:41:50 ubuntu-20 systemd[1]: Failed to start The plugin-driven server agent for reporting metrics into InfluxDB.