三、安装Prometheus
下载地址点击这里,本文下载的是Windows版本prometheus-2.17.2.windows-amd64.tar.gz。
解压后修改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: ['localhost:9090'] - job_name: 'monitor-demo' scrape_interval: 5s # 刮取的时间间隔 scrape_timeout: 5s metrics_path: /admin/prometheus scheme: http basic_auth: #认证信息 username: admin password: 1234 static_configs: - targets: - 127.0.0.1:8888 #此处填写 Spring Boot 应用的 IP + 端口号
更多配置信息请查看官方文档。
现在可以启动Prometheus了,命令行输入:prometheus.exe --config.file=prometheus.yml 访问http://localhost:9090/targets,查看Spring Boot采集状态是否正常。
四、安装Grafana
下载地址点击这里,本文用到的是Windows版本grafana-6.3.3.windows-amd64.zip。
解压后运行bin目录下的grafana-server.exe启动,游览器访问http://localhost:3000即可看到登录页面,默认账号密码是admin/admin。
现在开始创建自己的可视化监控面板。
1.设置数据源
2. 创建一个Dashboard
3. 填写采集的指标点
注意: 这里的指标点不能随便填,必须是已有的可以在 Prometheus看到。
4.选择图表样式
5.填写标题描述
最后点击右上角的保存,输入Dashboad的名称即可。