监控zookeeper集群

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#1.修改zookeeper配置文件
[root@elk03:2 ~]# vim /app/zookeeper/conf/zoo.cfg
···
metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
metricsProvider.httpHost=0.0.0.0
metricsProvider.httpPort=7000
metricsProvider.exportJvmInfo=true

#2.同步到其他节点
[root@elk01 ~]# scp /app/zookeeper/conf/zoo.cfg root@10.0.0.212:/app/zookeeper/conf/
[root@elk01 ~]# scp /app/zookeeper/conf/zoo.cfg root@10.0.0.213:/app/zookeeper/conf/

#3.重启zookeeper集群
[root@elk01 ~]# zkServer.sh restart
[root@elk02 ~]# zkServer.sh restart
[root@elk03 ~]# zkServer.sh restart

#4.测试访问zookeeper的监听端口是否正常
[root@elk03 ~]# curl -s 10.0.0.211:7000/metrics | head -3
# HELP approximate_data_size approximate_data_size
# TYPE approximate_data_size gauge
approximate_data_size 15794.0

#5.Prometheus配置zookeeper
[root@elk03:2 ~]# vim /softwares/prometheus-2.53.2.linux-amd64/prometheus.yml
···
- job_name: "zookeeper"
static_configs:
- targets:
- 10.0.0.211:7000
- 10.0.0.212:7000
- 10.0.0.213:7000

#6.检查Prometheus语法是否有误
[root@elk01:0 ~]# /softwares/prometheus-2.53.2.linux-amd64/promtool check config /softwares/prometheus-2.53.2.linux-amd64/prometheus.yml

#7.重新发起请求(热加载Prometheus)
[root@elk211 ~]# curl -X POST http://10.0.0.211:9090/-/reload

#8. 浏览器刷新访问,在target里即可看到被监控端
10.0.0.211:9090/targets

#grafana导入模板ID
10465

监控kafka集群

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#官方  https://prometheus.io/docs/instrumenting/exporters/  搜索kafka exporter

1.下载kafka exporter
wget https://github.com/danielqsj/kafka_exporter/releases/download/v1.8.0/kafka_exporter-1.8.0.linux-amd64.tar.gz

2.解压kafka exporter软件包 并做软连接
[root@elk01:3 ~]# tar xf kafka_exporter-1.8.0.linux-amd64.tar.gz -C /app/
[root@elk01:3 ~]# ln -s /app/kafka_exporter-1.8.0.linux-amd64/ /app/kafka-exporter

3.运行kafka exporter程序暴露kafka集群的指标提供http接口,以供Prometheus识别
[root@elk01:3 ~]# /app/kafka-exporter/kafka_exporter \
--web.listen-address=":9308" --web.telemetry-path="/metrics" \
--kafka.server=elk211:9092 --kafka.server=elk212:9092 \
--kafka.server=elk213:9092 --kafka.version="3.8.0"

4.访问kafka exporter测试
http://10.0.0.213:9308/metrics

5.Prometheus配置监控kafka
[root@elk03:2 ~]# vim /softwares/prometheus-2.53.2.linux-amd64/prometheus.yml
···
- job_name: "kafka"
static_configs:
- targets:
- 10.0.0.213:9308

6.检测Prometheus语法
7.热加载Prometheus

监控elasticsearch集群

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
1.下载elasticsearch exporter 
[root@elk01:3 ~]# wget https://github.com/prometheus-community/elasticsearch_exporter/releases/download/v1.7.0/elasticsearch_exporter-1.7.0.linux-amd64.tar.gz

2.解压软件包
[root@elk01:3 ~]# tar xf elasticsearch_exporter-1.7.0.linux-amd64.tar.gz -C /app

3.运行elasticsearch exporter暴露ES集群的监控指标为http接口,供给Prometheus抓取数据
[root@elk01:3 ~]# /app/elasticsearch_exporter-1.7.0.linux-amd64/elasticsearch_exporter \
--web.telemetry-path="/metrics" \
--web.listen-address=:9114 \
--es.all \
--es.uri="http://elastic:123456@10.0.0.211:9200"

4.访问elasticsearch exporter的WebUI
http://10.0.0.212:9114/metrics

5.Prometheus配置监控kafka
[root@elk03:2 ~]# vim /softwares/prometheus-2.53.2.linux-amd64/prometheus.yml
···
- job_name: "es"
static_configs:
- targets:
- 10.0.0.213:9114

6.检测Prometheus语法
7.热加载Prometheus