pattern-matchingtelegraftelegraf-inputs-plugintelegraf-plugins

Telegraf - inputs.procstat procstat Plugin - Using command line pattern or username


Using: Telegraf v1.0.1 or later

Telegraf procstat plugin's documentation: https://github.com/influxdata/telegraf/tree/master/plugins/inputs/procstat

Under Documentation, it says:

The procstat plugin can be used to monitor system resource usage by an individual process using their /proc data.

The plugin will tag processes by their PID and their process name.

Processes can be specified either by pid file, by executable name, by command line pattern matching, or by username (in this order or priority. Procstat plugin will use pgrep when executable name is provided to obtain the pid.

My custom config File:
/etc/telegraf/telegraf.d/my_custom_process_service-telegraf.conf contains:

[[inputs.procstat]]
  exe = "."
  prefix = "service_process"

[[inputs.procstat]]
  pid_file = "/var/run/jenkins/jenkins.pid"
  prefix = "service_process"

The above configuration works fine per the syntax.

Question:

The documentation says about using exe, pid_file, but it doesn't give an example on how to use the command line pattern matching OR by username. Can I get some examples if you know how to use it?


Solution

  • Found this info in the source file: https://github.com/influxdata/telegraf/blob/master/plugins/inputs/procstat/procstat.go (under variable var sampleConfig =

      ## Must specify one of: pid_file, exe, or pattern
      ## PID file to monitor process
      pid_file = "/var/run/nginx.pid"
    
      ## executable name (ie, pgrep <exe>)
      # exe = "nginx"
      ## pattern as argument for pgrep (ie, pgrep -f <pattern>)
    
      # pattern = "nginx"
      ## user as argument for pgrep (ie, pgrep -u <user>)
      # user = "nginx"
    
      ## override for process_name
      ## This is optional; default is sourced from /proc/<pid>/status
      # process_name = "bar"
    
      ## Field name prefix
      prefix = ""
    
    
      ## comment this out if you want raw cpu_time stats
      fielddrop = ["cpu_time_*"]
    
      ## This is optional; moves pid into a tag instead of a field
      pid_tag = false