前言

在之前的文档中,有了解Prometheus采集数据的三种方式,其中Exporters是最常用的方式。

官方提供了很多exporter,下载地址

如果官网找不到,但是也列述了很多开源社区提供的exporter。

node_exporter

GitHub地址
node_exporter用 Go 编写,带有可插入的指标收集器,是官方提供的硬件和操作系统指标exporter导出器。

监控多台Linux服务器案例步骤

1. 下载安装node_exporter

直接在官方下载压缩包安装,不建议将其部署为 Docker 容器,因为它需要访问主机系统。
在这里插入图片描述
解压,安装为服务启动。

# 上传并解压
[root@aaasds bin]# tar -zxvf node_exporter-1.2.2.linux-amd64.tar.gz
[root@aaasds bin]# cd node_exporter-1.2.2.linux-amd64/
[root@k3s002 opt]# mv node_exporter-1.2.2.linux-amd64/node_exporter /usr/local/bin/
[root@k3s002 opt]#  vi /etc/systemd/system/node_exporter.service 
# 添加如下内容
[Unit]
Description=node_exporter
After=network.target
[Service]
Type=simple
User=root
# 指定启动的端口和日志级别
ExecStart=/usr/local/bin/node_exporter --web.listen-address=:9109 --log.level=error
MemoryLimit=300M
CPUQuota=100%
Restart=on-failure
[Install]
WantedBy=multi-user.target
# 启动并设置开启自启
[root@aaasds node]#  systemctl daemon-reload
[root@aaasds node]# systemctl start  node_exporter.service
[root@aaasds node]# systemctl enable node_exporter.service
[root@aaasds node]# systemctl status node_exporter.service

在这里插入图片描述
然后访问IP+ 启动端口,出现以下页面,表示启动成功,其他服务器也按照这种方式安装即可。
在这里插入图片描述

2. Prometheus配置

[root@node8245 conf]# vim prometheus.yml 

在配置中添加一个名为nodes任务,并添加多个服务器地址,重启Prometheus。

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: ['192.168.8.25:9090']
   # Linux 服务器 监控 
  - job_name: nodes
    static_configs:
    # 添加多个服务器节点
    - targets: ['192.168.8.25:9109','192.168.8.23:9109']

进入Prometheus查看target,可以看到已经抓取到了node_exporter数据。
在这里插入图片描述

3. Grafana配置

Prometheus已经有数据了,接下来需要在Grafana导入仪表盘了。

Grafana首页点击加号,选择import导入。
在这里插入图片描述

这里可以直接输入官方网站中的仪表盘ID或者URL,联网的情况下比较好使,也可以直接复制Json文件。
在这里插入图片描述

官方网站搜索Node Export,直接选择中文版的。
在这里插入图片描述
点击后,复制ID。
在这里插入图片描述
在import页面中填入并点击Load。
在这里插入图片描述
然后填写仪表盘名称,选择数据源,点击导入。
在这里插入图片描述
然后就可以看到效果图了,搞定。
在这里插入图片描述

GitHub 加速计划 / pr / prometheus
6
0
下载
Prometheus是一个开源的监控和警报工具,用于监控Kubernetes应用程序和云基础设施的性能和可用性。 - 功能:监控;警报;性能管理;可用性管理;Kubernetes应用程序管理。 - 特点:高可用性;高性能;灵活的数据采集;与Kubernetes集成。
最近提交(Master分支:6 个月前 )
e04913ae feat(tsdb/(head|agent)): reuse pools across segments to reduce garbage during WL replay 10 天前
77a56981 When calculating dependencies between rules, we sometimes run into `{__name__...}` matchers These can be used the same way as the actual rule names This will enable even more rules to run concurrently The new logic is also not slower: ``` julienduchesne@triceratops prometheus % benchstat test-old.txt test.txt goos: darwin goarch: arm64 pkg: github.com/prometheus/prometheus/rules cpu: Apple M3 Pro │ test-old.txt │ test.txt │ │ sec/op │ sec/op vs base │ DependencyMap-11 1.206µ ± 7% 1.024µ ± 7% -15.10% (p=0.000 n=10) │ test-old.txt │ test.txt │ │ B/op │ B/op vs base │ DependencyMap-11 1.720Ki ± 0% 1.438Ki ± 0% -16.35% (p=0.000 n=10) │ test-old.txt │ test.txt │ │ allocs/op │ allocs/op vs base │ DependencyMap-11 39.00 ± 0% 34.00 ± 0% -12.82% (p=0.000 n=10) ``` Signed-off-by: Julien Duchesne <julien.duchesne@grafana.com> 10 天前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐