Prometheus监控ES集群
在配置前检查es集群状态是否存活
[root@elk1 ~]# curl -u elastic:123456 http://10.0.0.91:9200/_cat/nodes
10.0.0.91 43 95 0 0.39 0.30 0.27 cdfhilmrstw * elk1
10.0.0.92 27 96 0 0.49 0.38 0.26 cdfhilmrstw - elk2
10.0.0.93 33 97 1 0.33 0.31 0.26 cdfhilmrstw - elk3
这里我的集群测试 就没有加密 如果加密集群的话需要配置证书验证 或者使用-k参数来跳过验证
1.下载es exporter在客户端(监控的主机)
wget https://github.com/prometheus-community/elasticsearch_exporter/releases/download/v1.9.0/elasticsearch_exporter-1.9.0.linux-amd64.tar.gz
SVIP:
[root@elk1 ~]# wget http://192.168.16.253/Resources/Prometheus/softwares/elasticSearch_exporter/elasticsearch_exporter-1.9.0.linux-amd64.tar.gz
2.解压特定的程序
[root@elk1 ~]# tar xf elasticsearch_exporter-1.9.0.linux-amd64.tar.gz -C /usr/local/bin/ elasticsearch_exporter-1.9.0.linux-amd64/elasticsearch_exporter --strip-components=1
3.启动es exporter
[root@elk1 ~]# elasticsearch_exporter --es.uri="https://elastic:123456@10.0.0.91:9200" --es.ssl-skip-verify
ps:查看监听端口
![image-20250327193847968]()
4.访问测试es exporter的WebUI
http://10.0.0.91:9114/metrics
ps:集群的话就是将配置文件copy到对应节点 然后在服务端添加对应的主机信息就行
![image-20250327193015260]()
5.Prometheus配置监控es-exporter
[root@prometheus-server31 ~]# tail -5 /gsf/softwares/prometheus-2.53.4.linux-amd64/prometheus.yml
- job_name: es-exporter
static_configs:
- targets:
- 10.0.0.41:9114
文件末尾添加注意yml格式!!!
热加载
[root@prometheus-server31 ~]# curl -X POST http://10.0.0.31:9090/-/reload
![image-20250327193429299]()
6.验证Prometheus配置是否生效
http://10.0.0.31:9090/targets?search=
![image-20250327193554801]()
7.grafana导入模板ID
添加数据源
![image-20250327194133827]()
![image-20250327194432541]()
![image-20250327194645546]()
![image-20250327194749230]()
![image-20250327194854363]()
这里先推荐两个比较实用的模板,因为不太会写PromQL查询语句!
14191
9746
![image-20250327195002135]()
![image-20250327195124813]()
可以看到数据说明配置没啥问题 主要是Prom语句查询的问题! 这个模板id是9746 上一个好看但没啥数据 不出图
![image-20250327195522488]()