05 node-exporter配置模块黑白名单

# 参考格式说明:
	# TYPE:
		# 表示metric的数据类型。
	# HELP:
		# 表示metric帮助信息。
	# metric:
		# 具体的指标
	# 标签:
		# 给指标打标签,起到标识性作用
# 默认启用
https://github.com/prometheus/node_exporter?tab=readme-ov-file#enabled-by-default
# 默认禁用
https://github.com/prometheus/node_exporter?tab=readme-ov-file#disabled-by-default
# 查看帮助信息
[root@Prometheus-01 node_exporter-1.8.2.linux-amd64]# ./node_exporter --help
# Curl出的指标和浏览器里面看到的一样
[root@Prometheus-01 ~]# curl http://172.2.25.50:9100/metrics
...
# HELP node_cpu_seconds_total Seconds the CPUs spent in each mode.
# TYPE node_cpu_seconds_total counter
node_cpu_seconds_total{cpu="0",mode="idle"} 8442.6
node_cpu_seconds_total{cpu="0",mode="iowait"} 1.31
node_cpu_seconds_total{cpu="0",mode="irq"} 11.75
node_cpu_seconds_total{cpu="0",mode="nice"} 0.07
node_cpu_seconds_total{cpu="0",mode="softirq"} 43.07
node_cpu_seconds_total{cpu="0",mode="steal"} 0
node_cpu_seconds_total{cpu="0",mode="system"} 16.87
node_cpu_seconds_total{cpu="0",mode="user"} 12.33
node_cpu_seconds_total{cpu="1",mode="idle"} 8463.24
node_cpu_seconds_total{cpu="1",mode="iowait"} 3.8
node_cpu_seconds_total{cpu="1",mode="irq"} 28.89
node_cpu_seconds_total{cpu="1",mode="nice"} 0.15
node_cpu_seconds_total{cpu="1",mode="softirq"} 8.74
node_cpu_seconds_total{cpu="1",mode="steal"} 0
node_cpu_seconds_total{cpu="1",mode="system"} 20.76
node_cpu_seconds_total{cpu="1",mode="user"} 11.65
...
# 查看帮助
[root@Prometheus-01 node_exporter-1.8.2.linux-amd64]# ./node_exporter --help
...
      --[no-]collector.cpu       Enable the cpu collector (default: enabled).
      --[no-]collector.cpu_vulnerabilities 
...

01 黑名单

# 模块黑名单
[root@Prometheus-01 node_exporter-1.8.2.linux-amd64]# ./node_exporter --no-collector.cpu
# 这回就没有之前的模块了,其他指标正常
# 注意,只需要将"--no-collector.MODULE",将NAME换成你需要禁用的模块即可。
[root@Prometheus-01 ~]# curl http://172.2.25.50:9100/metrics | grep CPU
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0# HELP node_schedstat_running_seconds_total Number of seconds CPU spent running a process.
# HELP node_schedstat_timeslices_total Number of timeslices executed by CPU.
1# HELP node_schedstat_waiting_seconds_total Number of seconds spent by processing waiting for this CPU.
00 74246    0 7424# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
6    0     0  5178k      0 --:--:-- --:--:-- --:--:-- 5178k

02 白名单

# 指标只显示CPU和内核信息,其他不显示	--collector.disable-defaults:其他都禁用
[root@Prometheus-01 node_exporter-1.8.2.linux-amd64]# ./node_exporter --collector.cpu --collector.uname --collector.disable-defaults
posted @ 2025-02-26 08:52  Chains_1  阅读(17)  评论(0)    收藏  举报