telegraf service not able to retrieve data using the journalctl commands

21 Views Asked by At

I have a shell script which executes a series of command to get some server stats. Some of these commands are using journalctl to get the data.

The shell script collates all the data and creates a log file.

This log file is used by the telegraf service to send the output to InfluxDB.

The telegraf service is executing as teleraf user. This user telegraf is added to systemd-journal group so it can execute some of the journald commands.

When I run the telegraf command -test flag, the first execution is not showing the output for those commands which are using journalctl. If I run the same telegraf with -test flag again, I see the data coming up fine.

If I leave the telegraf service do what its supposed to do, the output of those journalctl commands are coming up as empty or null.

What could be happening here?

Sample commands from shell script:

....

chefver=$(journalctl -u chef-client --since "35 minutes ago" | grep -om 1 -E "Client, version [^;]*" | cut -d ' ' -f3 )

osver=$(hostnamectl | grep Operating | cut -d: -f2 | xargs)

...

In the above code, the chefver is coming as empty/null but osver value is showing up fine.

0

There are 0 best solutions below