influxdata / telegraf

Agent for collecting, processing, aggregating, and writing metrics, logs, and other arbitrary data.
https://influxdata.com/telegraf
MIT License
14.6k stars 5.57k forks source link

Telegraf service typo error in script file causes not loading it properly #8395

Closed alexcorvis84 closed 2 years ago

alexcorvis84 commented 3 years ago

Please check telegraf.service script shared.

There's a typo error which causes not loading config properly as the EnvironmentFile path is not declared ok.

Script shared:

[Service]
EnvironmentFile=-/etc/default/telegraf

It should be:

[Service]
EnvironmentFile=/etc/default/telegraf

Please, remove the -

reimda commented 3 years ago

The docs for systemd describe what the dash is for. (see https://www.freedesktop.org/software/systemd/man/systemd.exec.html)

"The argument passed should be an absolute filename or wildcard expression, optionally prefixed with "-", which indicates that if the file does not exist, it will not be read and no error or warning message is logged."

Can you share some more detail about the problem you had and how you solved it? I don't think the dash was the problem.

alexcorvis84 commented 3 years ago

Hi @reimda

My fault! You're absolutely right!

I was facing an issue with InfluxDB Cloud, where everytime the systemd service started I was receiving an error of unauthorized access to influxdb_v2.

I tweak so many files & workarounds.... that it finally worked & thought it was related with telegraf.service '- path issue' I found... yet it's not.

I've detected my personal issue:

I needed to setup the Telegraf environment variable INFLUX_TOKEN variable into /etc/default/telegraf. Then in the main config file (/etc/telegraf/telegraf.conf) I've set this environment variable needed for [[outputs.influxdb_v2]] as:

#   ## Token for authentication.
    token = "$INFLUX_TOKEN"

Now, everytime the system reboots, the service is working OK and uploading data to my InfluxDB Cloud bucket!

PS: Feedback -> This kind of setup should be detailed (or warned) in InfluxDB Cloud wizard setup instructions. As one of the steps is to copy/paste into shell "export INFLUX_TOKEN=" which is only valid for user session, not** permanent. So anyone which could setup Telegraf as systemd service would probably face the same issue as me if you don't pay attention to this important point ^^

Apologies and thank you for the feedback!

You can proceed to close the Issue.

mlbzssk commented 3 years ago

@reimda Hi!Can you help me look at this problem?I'm not sure what's wrong with the way I use it or anything.Thank you in advance. Issue: https://github.com/influxdata/telegraf/issues/8394

afikac commented 2 years ago

This is still broken. Just did scratch build on Ubuntu... Running telegraf 1.24 and influxdb OSS 2.4

Editing the systemd service file and removing the hyphen definitely works as temporary workaround... but a from scratch build is broken and won't read environmental variables from /etc/default/telegraf without doing this workaround.