Prometheus监控kafka集群
测试环境说明
准备用来测试的服务器,信息如下:
| 作用 | ip | 端口 |
|---|---|---|
| Prometheus服务端 数据存储、数据采集、提供webUI | 10.0.0.51 | 9090 |
| grafana | 10.0.0.51 | 3000 |
| zok-node01、kafka-node01 | 10.0.0.66 | 2888:3888 |
| zok-node02、kafka-node02 | 10.0.0.67 | 2888:3888 |
| zok-node03、kafka-node03 | 10.0.0.68 | 2888:3888 |
前置环境说明:
1.已经安装了prometheus-server
推荐阅读:
二进制部署Prometheus-server及自动化部署讲解(2)-CSDN博客
2.已经安装了grafana
推荐阅读:
1.构建可视化监控系统:Grafana 安装配置、官方 Dashboard 应用与插件扩展-CSDN博客
3.grafana已经导入了prometheus数据源
推荐阅读:
1.构建可视化监控系统:Grafana 安装配置、官方 Dashboard 应用与插件扩展-CSDN博客
4.已经安装了zookeeper集群、kafka集群。
一、客户端采集数据
kafka不自动metrics接口,需要安装第三方的exporter。
1.下载第三方的exporter

上传到服务器
[root@es01 ~]# ll kafka_exporter-1.9.0.linux-amd64.tar.gz
-rw-r--r-- 1 root root 12733803 Nov 3 15:41 kafka_exporter-1.9.0.linux-amd64.tar.gz
[root@es01 ~]#
2.安装exporter(3节点kafka,通常其中一台安装exporter就可以了)
[root@es01 ~]# tar xf kafka_exporter-1.9.0.linux-amd64.tar.gz -C /usr/local/bin/
[root@es01 ~]#
[root@es01 ~]# ll /usr/local/bin/kafka_exporter-1.9.0.linux-amd64/kafka_exporter
-rwxr-xr-x 1 1001 fwupd-refresh 25099148 Feb 17 2025 /usr/local/bin/kafka_exporter-1.9.0.linux-amd64/kafka_exporter*
[root@es01 ~]#
启动kafka exporter
[root@es01 ~]# /usr/local/bin/kafka_exporter-1.9.0.linux-amd64/kafka_exporter --kafka.version="3.9.0" --kafka.server=10.0.0.66:9092 --web.listen-address=":9308" --web.telemetry-path="/metrics"
I1103 15:49:54.146906 6206 kafka_exporter.go:850] Starting kafka_exporter (version=1.9.0, branch=HEAD, revision=8ec24078707d4d3b349e71522ebd7f179746072d)
I1103 15:49:54.692376 6206 kafka_exporter.go:1021] Listening on HTTP :9308
验证客户端的metrics接口

二、配置Prometheus的服务发现(静态监控目标)
配置文件路径:
$INSTALLDIR/prometheus-2.53.2.linux-amd64/prometheus.yml
1.编辑配置文件
新增一个job任务:
采集客户端的kafka集群的http接口
65 #kafka-exporter
66 - job_name: "kafka-exporter"
67
68 # metrics_path defaults to '/metrics'
69 # scheme defaults to 'http'.
70
71 static_configs:
72 - targets:
73 - 10.0.0.66:9308
2.热加载生效
[root@prometheus-server51 prometheus]# !curl
curl -X POST 10.0.0.51:9090/-/reload
3.验证
3.1打开prome的WebUI,查看job任务是否加载成功
http://10.0.0.51:9090/targets?search=

三、grafana展示监控
一、部署grafana
二、配置grafana
1.添加Prometheus数据源
2.新建dashboard

Prometheus监控ElasticSearch集群
测试环境说明
准备用来测试的服务器,信息如下:
| 作用 | ip | 端口 |
|---|---|---|
| Prometheus服务端 数据存储、数据采集、提供webUI | 10.0.0.51 | 9090 |
| grafana | 10.0.0.51 | 3000 |
| elastic-node01 | 10.0.0.66 | 9200/9300 |
| elastic-node02 | 10.0.0.67 | 9200/9300 |
| elastic-node03 | 10.0.0.68 | 9200/9300 |
前置环境说明:
1.已经安装了prometheus-server
推荐阅读:
二进制部署Prometheus-server及自动化部署讲解(2)-CSDN博客
2.已经安装了grafana
推荐阅读:
1.构建可视化监控系统:Grafana 安装配置、官方 Dashboard 应用与插件扩展-CSDN博客
3.grafana已经导入了prometheus数据源
推荐阅读:
1.构建可视化监控系统:Grafana 安装配置、官方 Dashboard 应用与插件扩展-CSDN博客
一、客户端采集数据
elastic不自带metrics接口,需要部署第三方exporter来提供数据采集的metrics接口。
1.下载第三方exporter
Exporters and integrations | Prometheus


上传到服务器
[root@es01 ~]# ll elasticsearch_exporter-1.9.0.linux-amd64.tar.gz
-rw-r--r-- 1 root root 5656427 Nov 3 16:16 elasticsearch_exporter-1.9.0.linux-amd64.tar.gz
[root@es01 ~]#
2.安装exporter
解压软件包
[root@es01 ~]# tar xf elasticsearch_exporter-1.9.0.linux-amd64.tar.gz -C /usr/local/bin/
[root@es01 ~]# ll /usr/local/bin/elasticsearch_exporter-1.9.0.linux-amd64/elasticsearch_exporter
-rwxr-xr-x 1 1001 fwupd-refresh 15069336 Mar 3 2025 /usr/local/bin/elasticsearch_exporter-1.9.0.linux-amd64/elasticsearch_exporter*
[root@es01 ~]#
启动exporter
[root@es01 ~]# /usr/local/bin/elasticsearch_exporter-1.9.0.linux-amd64/elasticsearch_exporter --es.uri="http://elastic:xG03WjIkeceDshYest6Y@10.0.0.66:9200" --web.listen-address=:9114 --web.telemetry-path="/metrics" --es.ssl-skip-verify
time=2026-11-03T08:19:11.270Z level=INFO source=clusterinfo.go:211 msg="triggering initial cluster info call"
time=2026-11-03T08:19:11.272Z level=INFO source=clusterinfo.go:182 msg="providing consumers with updated cluster info label"
time=2026-11-03T08:19:11.538Z level=INFO source=main.go:244 msg="started cluster info retriever" interval=5m0s
time=2026-11-03T08:19:11.544Z level=INFO source=tls_config.go:347 msg="Listening on" address=[::]:9114
time=2026-11-03T08:19:11.546Z level=INFO source=tls_config.go:350 msg="TLS is disabled." http2=false address=[::]:9114
3.访问ElasticSearch-exporter的webUI

二、配置Prometheus的服务发现(静态监控目标)
配置文件路径:
$INSTALLDIR/prometheus-2.53.2.linux-amd64/prometheus.yml
1.编辑配置文件
新增一个job任务:
采集客户端es集群的http接口
75 #elastic-exporter
76 - job_name: "elastic-exporter"
77
78 # metrics_path defaults to '/metrics'
79 # scheme defaults to 'http'.
80
81 static_configs:
82 - targets:
83 - 10.0.0.66:9114

2.热加载生效
[root@prometheus-server51 prometheus]# !curl
curl -X POST 10.0.0.51:9090/-/reload
3.验证
3.1打开prome的WebUI,查看job任务是否加载成功
http://10.0.0.51:9090/targets?search=

三、grafana展示监控
一、部署grafana
二、配置grafana
1.添加Prometheus数据源
2.新建dashboard

Prometheus监控redis案例
测试环境说明
准备用来测试的服务器,信息如下:
| 作用 | ip | 端口 |
|---|---|---|
| Prometheus服务端 数据存储、数据采集、提供webUI | 10.0.0.51 | 9090 |
| grafana | 10.0.0.51 | 3000 |
| reids | 10.0.0.51 | 6379 |
前置环境说明:
1.已经安装了prometheus-server
推荐阅读:
二进制部署Prometheus-server及自动化部署讲解(2)-CSDN博客
2.已经安装了grafana
推荐阅读:
1.构建可视化监控系统:Grafana 安装配置、官方 Dashboard 应用与插件扩展-CSDN博客
3.grafana已经导入了prometheus数据源
推荐阅读:
1.构建可视化监控系统:Grafana 安装配置、官方 Dashboard 应用与插件扩展-CSDN博客
零、部署redis
1.拉镜像
[root@prometheus-server51 ~]# docker pull redis:7.4.2-alpine
7.4.2-alpine: Pulling from library/redis
f18232174bc9: Pull complete
16cd0457255f: Pull complete
fa05f5234346: Pull complete
4d03bd351ab9: Pull complete
4738865c5f32: Pull complete
927ba88b2847: Pull complete
4f4fb700ef54: Pull complete
4c7f0522bc7d: Pull complete
Digest: sha256:02419de7eddf55aa5bcf49efb74e88fa8d931b4d77c07eff8a6b2144472b6952
Status: Downloaded newer image for redis:7.4.2-alpine
docker.io/library/redis:7.4.2-alpine
2.启动容器
[root@prometheus-server51 ~]# docker run -d --name redis-server --network host redis:7.4.2-alpine
199142a1467499e3b5356e04e4689eac0708f46c4340ff71da369acb5b709c33
[root@prometheus-server51 ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
199142a14674 redis:7.4.2-alpine "docker-entrypoint.s..." 5 seconds ago Up 4 seconds redis-server
验证
[root@prometheus-server51 ~]# ss -tnulp |grep 6379
tcp LISTEN 0 511 0.0.0.0:6379 0.0.0.0:* users:(("redis-server",pid=2007,fd=6))
tcp LISTEN 0 511 [::]:6379 [::]:* users:(("redis-server",pid=2007,fd=7))

3.写入测试数据
[root@prometheus-server51 ~]# docker exec -it redis-server sh
/data # redis-cli -n 5
127.0.0.1:6379[5]> KEYS *
(empty array)
127.0.0.1:6379[5]> set test redis
OK
127.0.0.1:6379[5]> KEYS *
1) "test"
127.0.0.1:6379[5]>
一、客户端采集数据
redis本身不自带metrics接口,需要下载第三方exporter
1.下载exporter
Exporters and integrations | Prometheus

1.74.0版本

2.上传到服务器
[root@prometheus-server51 ~]# ll redis_exporter-v1.74.0.linux-amd64.tar.gz
-rw-r--r-- 1 root root 3829617 Nov 5 10:51 redis_exporter-v1.74.0.linux-amd64.tar.gz
[root@prometheus-server51 ~]#
3.部署exporter
解压
[root@prometheus-server51 ~]# tar xf redis_exporter-v1.74.0.linux-amd64.tar.gz -C /usr/local/bin/
[root@prometheus-server51 ~]# ll /usr/local/bin/redis_exporter-v1.74.0.linux-amd64/redis_exporter
-rwxr-xr-x 1 1001 fwupd-refresh 9646264 Jun 8 2025 /usr/local/bin/redis_exporter-v1.74.0.linux-amd64/redis_exporter*
[root@prometheus-server51 ~]#
运行
[root@prometheus-server51 ~]# /usr/local/bin/redis_exporter-v1.74.0.linux-amd64/redis_exporter -redis.addr redis://10.0.0.51:6379 -web.telemetry-path /metrics -web.listen-address :9121
INFO[0000] Redis Metrics Exporter v1.74.0 build date: 2025-06-08-02:08:38 sha1: 009602959fd20c5a78de639490745c8bbc7b2e06 Go: go1.24.4 GOOS: linux GOARCH: amd64
INFO[0000] Providing metrics at :9121/metrics
检查exporter的metrics接口

二、配置Prometheus服务发现(静态监控目标)
1.编辑配置文件
新增一个job任务:
采集客户端redis-exporter的http接口
85 #redis-exporter
86 - job_name: "redis-exporter"
87
88 # metrics_path defaults to '/metrics'
89 # scheme defaults to 'http'.
90
91 static_configs:
92 - targets:
93 - 10.0.0.51:9121

2.热加载生效
3.验证
3.1打开prome的WebUI,查看job任务是否加载成功
http://10.0.0.51:9090/targets?search=

三、grafana展示监控
一、部署grafana
二、配置grafana
1.添加Prometheus数据源
2.新建dashboard
