目标要求
1、需要展现的仪表盘:
SpringBoot或JVM仪表盘
Centos物理机服务器(实际为物理分割的虚拟服务器)仪表盘
2、展现要求:
探索Prometheus + Grafana搭建起来的展示效果,尽可能展示能展示的部分。
新建工作目录prometheus,将下载的软件包移动到目录下。
使用“tar -zxvf 软件包包名”命令逐步接下软件包。
如: tar -zxvf prometheus-2.45.0.linux-amd64.tar.gz
在每个解压后的软件工作目录,新建start.sh脚本,按下方表格填入启动命令。保存后,赋予脚本执行权限“chmod +x start.sh”。
| 关闭方式 | 启动脚本 | |
|---|---|---|
| prometheus | kill -9 | nohup ./prometheus --web.enable-lifecycle > log.log 2>&1 & |
| grafana | 同上 | nohup ./bin/grafana-server>>./log.log & |
| node | 同上 | nohup ./node_exporter --web.listen-address=:9101 > node_log.log 2>&1 & |
分别执行目录下的启动脚本:start.sh


初始账户密码:admin/admin
初次安装需要修改密码,按照提示修改即可。登录后正常访问效果图如下:

JAVA版本:JDK17,Springboot版本:3.1.2
org.springframework.boot
spring-boot-starter-actuator
2.1.4.RELEASE
io.micrometer
micrometer-core
1.11.1
io.micrometer
micrometer-registry-prometheus
1.11.1
# prometheus 配置
management:
metrics:
# 下面选项建议打开,以监控 http 请求的 P99/P95 等,具体的时间分布可以根据实际情况设置
distribution:
sla:
http:
server:
requests: 1ms,5ms,10ms,50ms,100ms,200ms,500ms,1s,5s
tags:
application: ${spring.application.name}
endpoints:
prometheus:
enabled: true
web:
base-path: /monitor
exposure:
include: "prometheus"

scrape_configs:
# The job name is added as a label `job=` to any timeseries scraped from this config.
- job_name: "prometheus"
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
# 添加应用节点
- job_name: 'application'
metrics_path: '/monitor/prometheus'
scrape_interval: 15s
file_sd_configs:
- files: ['./exporter_config/application_target.json']
# 添加硬件节点
- job_name: 'node'
scrape_interval: 15s
file_sd_configs:
- files: ['./exporter_config/node.json']
static_configs:
- targets: ["localhost:9090"]

10.0.0.1:100x代表节点、jar包所在的机器ip以及端口号
application_target.json
[
{
"targets": [
"10.0.0.1:1001"
],
"labels": {
"instance": "10.0.0.1:1001",
"service": "jar名",
"ip": "10.0.0.1",
"nodeType": "application"
}
}
]
node.json
[
{
"targets":[
"10.0.0.1:1001"
],
"labels":{
"instance":"模拟硬件节点",
"job":"模拟硬件节点job",
"ip": "10.0.0.1",
"nodeType":"device"
}
}
]







任意Dashboard,无需数据源可导入,但是展示的内容是默认值。
同类型的多个监控目标,例如node监控,可以在适配的Dashboard切换观看。












