Process Exporter

如果grafana-agent运行在container中,那么在容器的启动命令中,要做以下调整,即将宿主机的/proc目录映射到容器中相应的位置。

如果grafana-agent运行在Kubernetes中,那么同样的需要在manifest文件中,做如下调整,即将宿主机的/proc目录映射到容器中相应的位置。

  1. apiVersion: v1
  2. kind: Pod
  3. metadata:
  4. name: grafana-agent
  5. spec:
  6. containers:
  7. - image: grafana/agent:v0.23.0
  8. name: agent
  9. args:
  10. - --config.file=/etc/agent-config/agent.yaml
  11. volumeMounts:
  12. - name: procfs
  13. mountPath: /proc
  14. readOnly: true
  15. volumes:
  16. - name: procfs
  17. hostPath:
  18. path: /proc

配置并启用process_exporter

采集的指标列表

  1. # Context switches
  2. # 上下文切换数量
  3. # Counter
  4. namedprocess_namegroup_context_switches_total
  5. # Cpu user/system usage in seconds
  6. # CPU 时间(秒)
  7. # Counter
  8. namedprocess_namegroup_cpu_seconds_total
  9. # Major page faults
  10. # 主要页缺失次数
  11. # Counter
  12. namedprocess_namegroup_major_page_faults_total
  13. # Minor page faults
  14. # 次要页缺失次数
  15. # Counter
  16. namedprocess_namegroup_minor_page_faults_total
  17. # number of bytes of memory in use
  18. # 内存占用(byte)
  19. # number of processes in this group
  20. # 同名进程数量
  21. # Gauge
  22. namedprocess_namegroup_num_procs
  23. # Number of processes in states Running, Sleeping, Waiting, Zombie, or Other
  24. # 同名进程状态分布
  25. # Gauge
  26. namedprocess_namegroup_states
  27. # Number of threads
  28. # 线程数量
  29. # Gauge
  30. namedprocess_namegroup_num_threads
  31. # start time in seconds since 1970/01/01 of oldest process in group
  32. # 启动时间戳
  33. # Gauge
  34. namedprocess_namegroup_oldest_start_time_seconds
  35. # number of open file descriptors for this group
  36. # 打开文件描述符数量
  37. # Gauge
  38. namedprocess_namegroup_open_filedesc
  39. # the worst (closest to 1) ratio between open fds and max fds among all procs in this group
  40. # 打开文件数 / 允许打开文件数
  41. # Gauge
  42. namedprocess_namegroup_worst_fd_ratio
  43. # number of bytes read by this group
  44. # 读数据量(byte)
  45. # Counter
  46. namedprocess_namegroup_read_bytes_total
  47. # number of bytes written by this group
  48. # 写数据量(byte)
  49. # Counter
  50. namedprocess_namegroup_write_bytes_total
  51. # Number of threads in this group waiting on each wchan
  52. # Gauge
  53. namedprocess_namegroup_threads_wchan

process_exporter的详细配置项说明

  1. # The name to use for identifying the process group name in the metric. By
  2. # default, it uses the base path of the executable.
  3. #
  4. # The following template variables are available:
  5. #
  6. # - {{.Comm}}: Basename of the original executable from /proc/<pid>/stat
  7. # - {{.ExeBase}}: Basename of the executable from argv[0]
  8. # - {{.ExeFull}}: Fully qualified path of the executable
  9. # - {{.Username}}: Username of the effective user
  10. # - {{.Matches}}: Map containing all regex capture groups resulting from
  11. # matching a process with the cmdline rule group.
  12. # - {{.PID}}: PID of the process. Note that the PID is copied from the
  13. # first executable found.
  14. # - {{.StartTime}}: The start time of the process. This is useful when combined
  15. # with PID as PIDS get reused over time.
  16. [name: <string> | default = "{{.ExeBase}}"]
  17. # A list of strings that match the base executable name for a process, truncated
  18. # at 15 characters. It is derived from reading the second field of
  19. # /proc/<pid>/stat minus the parens.
  20. #
  21. # If any of the strings match, the process will be tracked.
  22. comm:
  23. [- <string>]
  24. # A list of strings that match argv[0] for a process. If there are no slashes,
  25. # only the basename of argv[0] needs to match. Otherwise the name must be an
  26. # exact match. For example, "postgres" may match any postgres binary but
  27. # "/usr/local/bin/postgres" can only match a postgres at that path exactly.
  28. #
  29. # If any of the strings match, the process will be tracked.
  30. exe:
  31. [- <string>]
  32. # A list of regular expressions applied to the argv of the process. Each
  33. # regex here must match the corresponding argv for the process to be tracked.
  34. # The first element that is matched is argv[1].
  35. #
  36. # Regex Captures are added to the .Matches map for use in the name.
  37. cmdline: