I’m attempting to use Telegraf’s procstat plugin to monitor the status of the filebeat process on a server and write this data into InfluxDB.
First, I created a demo to confirm that my procstat plugin works correctly. My configuration file is as follows:
[global_tags]
ip_address = "xxxxxx"
[agent]
interval = "5s"
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = "0s"
flush_interval = "10s"
flush_jitter = "0s"
precision = "0s"
hostname= ""
omit_hostname = false
[[outputs.influxdb_v2]]
urls = ["http://xxxxxx:8086"]
token = "xxxxxx"
organization = "xxxxxx"
bucket = "telegraf"
[[inputs.procstat]]
pattern = "filebeat"
metric_version = 2
After starting Telegraf, I could successfully see the collected information in InfluxDB. Due to the possibility of multiple filebeat processes (with binaries located in different directories) running on the server, I wanted to specify the absolute path to the filebeat binary. Therefore, I modified my Telegraf configuration file as follows:
[global_tags]
ip_address = "xxxxxx"
... ...
[[inputs.procstat]]
exe = "/usr/share/filebeat/bin/filebeat"
metric_version = 2
Also not working for below configuration:
[global_tags]
ip_address = "xxxxxx"
... ...
[[inputs.procstat]]
cmdline = "/usr/share/filebeat/bin/filebeat.*"
metric_version = 2
After restarting the Telegraf service, I found that it could no longer collect process information.
Regarding the monitored process itself, the following command line output is provided for reference:
# ps -aux | grep filebeat | grep -v grep
root 979 0.0 0.0 3196572 22652 ? Ssl 2024 206:10 /usr/share/filebeat/bin/filebeat -c /etc/filebeat/filebeat.yml -path.home /usr/share/filebeat -path.config /etc/filebeat -path.data /var/lib/filebeat -path.logs /var/log/filebeat
# pgrep -l filebeat
979 filebeat
# cat /proc/979/cmdline
/usr/share/filebeat/bin/filebeat-c/etc/filebeat/filebeat.yml-path.home/usr/share/filebeat-path.config/etc/filebeat-path.data/var/lib/filebeat-path.logs/var/log/filebeat