Prometheus 监控linux服务器
Prometheus 监控linux服务器
node_exporter:用于*NIX系统监控,使用Go语言编写的收集器。
- 使用版本
- node_exporter 0.17.0
- 相关文档
- 使用文档:https://prometheus.io/docs/guides/node-exporter/
- GitHub:https://github.com/prometheus/node_exporter
- exporter列表:https://prometheus.io/docs/instrumenting/exporters/
- 百度云下载:node_exporter 0.17.0
- 地址:https://pan.baidu.com/s/1kXKs6oiGFwubsJ-cGvWykg
- 密码:vrpk
安装监控客户端
1、下载到被监控的linux系统
下载地址:https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz
2、解压压缩包
[root@server02 ~]# tar xvfz node_exporter-0.17.0.linux-amd64.tar.gz
3、移动并进入目录
[root@server02 ~]# mv node_exporter-0.17.0.linux-amd64 /usr/local/node_exporter
4、启动node_exporter服务,默认9100端口
[root@server02 ~]# cd /usr/local/node_exporter
[root@server02 node_exporter]# ./node_exporter
常用参数: # 收集文件系统,忽略哪些不搜集 --collector.filesystem.ignored-mount-points="^/(dev|proc|sys|var/lib/docker/.+)($|/)" # 管理的系统服务 --collector.systemd.unit-whitelist=".+" # 指定监听端口 默认9100 --web.listen-address=":9100" 常用启动参数
5、添加系统服务:vi /usr/lib/systemd/system/node_exporter.service
[Unit] Description=https://prometheus.io [Service] Restart=on-failure ExecStart=/usr/local/node_exporter/node_exporter --conllector.systemd --conllector.systemd.unit-whitelist=(docker|kubelet|kube-proxy|flanneld).service [Install] WantedBy=multi-user.target
6、启动添加后的系统服务
systemctl daemon-reload
systemctl restart node_exporter
7、查看导出器导出的数据信息:http://192.168.1.221:9100/metrics
# HELP go_gc_duration_seconds A summary of the GC invocation durations. # TYPE go_gc_duration_seconds summary go_gc_duration_seconds{quantile="0"} 0 go_gc_duration_seconds{quantile="0.25"} 0 go_gc_duration_seconds{quantile="0.5"} 0 go_gc_duration_seconds{quantile="0.75"} 0 go_gc_duration_seconds{quantile="1"} 0 go_gc_duration_seconds_sum 0 go_gc_duration_seconds_count 0 # HELP go_goroutines Number of goroutines that currently exist. # TYPE go_goroutines gauge go_goroutines 7 # HELP go_info Information about the Go environment. # TYPE go_info gauge go_info{version="go1.11.2"} 1 # HELP go_memstats_alloc_bytes Number of bytes allocated and still in use. # TYPE go_memstats_alloc_bytes gauge go_memstats_alloc_bytes 1.075736e+06 # HELP go_memstats_alloc_bytes_total Total number of bytes allocated, even if freed. # TYPE go_memstats_alloc_bytes_total counter go_memstats_alloc_bytes_total 1.075736e+06 # HELP go_memstats_buck_hash_sys_bytes Number of bytes used by the profiling bucket hash table.
使用prometheus监控客户端实例
1、添加新的job服务发现获取新的node:vim prometheus.yml
scrape_configs: # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config. - job_name: 'prometheus' # metrics_path defaults to '/metrics' # scheme defaults to 'http'. static_configs: - targets: ['server04:9090'] - job_name: 'server02' file_sd_configs: - files: ['/usr/local/prometheus/sd_config/node01.yml'] refresh_interval: 5s - job_name: 'server03' file_sd_configs: - files: ['/usr/local/prometheus/sd_config/node02.yml'] refresh_interval: 5s
2、新建配置文件并添加node:vim /usr/local/prometheus/sd_config/node.yml
[root@server04 sd_config]# ll 总用量 8 -rw-r--r-- 1 root root 34 6月 8 22:09 node01.yml -rw-r--r-- 1 root root 34 6月 8 22:12 node02.yml [root@server04 sd_config]# cat node01.yml node02.yml - targets: - 192.168.1.221:9100 - targets: - 192.168.1.222:9100

5、通过promSQL进行简单查询


浙公网安备 33010602011771号