Process Exporter
如果grafana-agent运行在container中,那么在容器的启动命令中,要做以下调整,即将宿主机的/proc目录映射到容器中相应的位置。
如果grafana-agent运行在Kubernetes中,那么同样的需要在manifest文件中,做如下调整,即将宿主机的/proc目录映射到容器中相应的位置。
apiVersion: v1
kind: Pod
metadata:
name: grafana-agent
spec:
containers:
- image: grafana/agent:v0.23.0
name: agent
args:
- --config.file=/etc/agent-config/agent.yaml
volumeMounts:
- name: procfs
mountPath: /proc
readOnly: true
volumes:
- name: procfs
hostPath:
path: /proc
配置并启用process_exporter
采集的指标列表
# Context switches
# 上下文切换数量
# Counter
namedprocess_namegroup_context_switches_total
# Cpu user/system usage in seconds
# CPU 时间(秒)
# Counter
namedprocess_namegroup_cpu_seconds_total
# Major page faults
# 主要页缺失次数
# Counter
namedprocess_namegroup_major_page_faults_total
# Minor page faults
# 次要页缺失次数
# Counter
namedprocess_namegroup_minor_page_faults_total
# number of bytes of memory in use
# 内存占用(byte)
# number of processes in this group
# 同名进程数量
# Gauge
namedprocess_namegroup_num_procs
# Number of processes in states Running, Sleeping, Waiting, Zombie, or Other
# 同名进程状态分布
# Gauge
namedprocess_namegroup_states
# Number of threads
# 线程数量
# Gauge
namedprocess_namegroup_num_threads
# start time in seconds since 1970/01/01 of oldest process in group
# 启动时间戳
# Gauge
namedprocess_namegroup_oldest_start_time_seconds
# number of open file descriptors for this group
# 打开文件描述符数量
# Gauge
namedprocess_namegroup_open_filedesc
# the worst (closest to 1) ratio between open fds and max fds among all procs in this group
# 打开文件数 / 允许打开文件数
# Gauge
namedprocess_namegroup_worst_fd_ratio
# number of bytes read by this group
# 读数据量(byte)
# Counter
namedprocess_namegroup_read_bytes_total
# number of bytes written by this group
# 写数据量(byte)
# Counter
namedprocess_namegroup_write_bytes_total
# Number of threads in this group waiting on each wchan
# Gauge
namedprocess_namegroup_threads_wchan
process_exporter的详细配置项说明
# The name to use for identifying the process group name in the metric. By
# default, it uses the base path of the executable.
#
# The following template variables are available:
#
# - {{.Comm}}: Basename of the original executable from /proc/<pid>/stat
# - {{.ExeBase}}: Basename of the executable from argv[0]
# - {{.ExeFull}}: Fully qualified path of the executable
# - {{.Username}}: Username of the effective user
# - {{.Matches}}: Map containing all regex capture groups resulting from
# matching a process with the cmdline rule group.
# - {{.PID}}: PID of the process. Note that the PID is copied from the
# first executable found.
# - {{.StartTime}}: The start time of the process. This is useful when combined
# with PID as PIDS get reused over time.
[name: <string> | default = "{{.ExeBase}}"]
# A list of strings that match the base executable name for a process, truncated
# at 15 characters. It is derived from reading the second field of
# /proc/<pid>/stat minus the parens.
#
# If any of the strings match, the process will be tracked.
comm:
[- <string>]
# A list of strings that match argv[0] for a process. If there are no slashes,
# only the basename of argv[0] needs to match. Otherwise the name must be an
# exact match. For example, "postgres" may match any postgres binary but
# "/usr/local/bin/postgres" can only match a postgres at that path exactly.
#
# If any of the strings match, the process will be tracked.
exe:
[- <string>]
# A list of regular expressions applied to the argv of the process. Each
# regex here must match the corresponding argv for the process to be tracked.
# The first element that is matched is argv[1].
#
# Regex Captures are added to the .Matches map for use in the name.
cmdline: