目录
一、springboot项目配置
pom.xml
|
application.properties
|
配置好后启动springboot项目访问 http://localhost:8086/actuator/prometheus 看到以下页面即说明配置成功
http://localhost:8086/actuator看到所有的
如果项目有登录拦截,在项目中将路径 /actuator/* 设置免登陆可访问
二、springboot项目接入prometheu
在服务器上已经安装了docker的前提
增加监控进程修改配置
vim /etc/prometheus/prometheus.yml
新增一条类似如下的记录
global:
scrape_interval: 60s
evaluation_interval: 60s
scrape_configs:
- job_name: prometheus
metrics_path: '/actuator/prometheus'
static_configs:
- targets: ['springboot项目ip:端口']
启动prometheus
docker run -p 9090:9090 --name=-prometheus -v /etc/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus &
如果已经有同名进程启动,需要杀死进程执行
docker rm prometheus
访问http://localhost:9090/ ,看见如下界面说明启动成功
三、配置Grafana
1、从官网下载,安装https://grafana.com/grafana/download
2、启动,访问:http://localhost:3000/ 默认账户密码 admin/admin
3、配置数据源
4、新增看板
从http://localhost:8086/actuator/prometheus 查看参数(就是你要监控的那个springboot项目)
配置完后保存即可