[TOC]
prometheus上传prometheus安装包至lab3服务器/opt/modules/目录下并解压
tar -zxf prometheus-2.32.1.linux-amd64.tar.gz
进入/opt/modules/prometheus-2.32.1目录,修改prometheus.yml文件
vi 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: ["lab3:9090"]
- job_name: "node exporter"
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['lab1:8100', 'lab2:8100', 'lab3:8100']
- job_name: "kafka exporter"
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['lab3:9308']
在/opt/modules/prometheus-2.32.1目录下启动prometheus
nohup ./prometheus --config.file=prometheus.yml > ./prometheus.log 2>&1 &
查看9090端口状态或浏览器访问http://lab3:9090验证是否成功
lsof -i:9090
node_exporter上传node_exporter安装包至lab3服务器/opt/modules/目录下并解压
tar -zxf node_exporter-1.3.1.linux-amd64.tar.gz
进入/opt/modules/node_exporter-1.3.1目录,启动node_exporter
nohup ./node_exporter --web.listen-address=:8100 &
查看8100端口状态或浏览器访问http://lab3:8100/metrics验证是否成功
lsof -i:8100
在lab1和lab2上重复上述步骤
kafka_exporter上传kafka_exporter安装包至lab3服务器/opt/modules/目录下并解压
tar -zxf kafka_exporter-1.4.2.linux-amd64.tar.gz
进入/opt/modules/kafka_exporter-1.4.2目录,启动kafka_exporter
nohup ./kafka_exporter --kafka.server=lab3:9092 > kafka_exporter.log --web.listen-address=:9308 &
查看9308端口状态或浏览器访问http://lab3:9308/metrics验证是否成功
lsof -i:9308
grafana上传grafana至lab3服务器/opt/modules/目录
进入/opt/modules/grafana-8.3.4目录,启动grafana
nohup ./bin/grafana-server web > ./grafana.log 2>&1 &
查看3000端口状态或浏览器访问http://lab3:3000/验证是否成功
lsof -i:3000
访问http://lab3:3000, 用户和密码均为admin
进入左侧设置,配置prometheus数据源及mysql数据源
| 软件 | 版本 | 安装位置 |
|---|---|---|
| prometheus | 2.32.1 | lab3 |
| node_exporter | 1.3.1 | lab1,lab2,lab3 |
| kafka_exporter | 1.4.2 | lab3 |
| grafana | 8.3.4 | lab3 |