SpringBoot可視化監(jiān)控的具體應(yīng)用
本文主要介紹了Spring Boot 應(yīng)用可視化監(jiān)控,分享給大家,具體如下:

1、Spring Boot 應(yīng)用暴露監(jiān)控指標(biāo)【版本 1.5.7.RELEASE】
首先,添加依賴如下依賴:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
/*采集應(yīng)用的指標(biāo)信息,我們使用的是prometheus,相應(yīng)的我們引入包:*/
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_spring_boot</artifactId> <version>0.0.26</version>
</dependency>
然后,在啟動(dòng)類 Application.java 添加如下注解:
@SpringBootApplication
@EnablePrometheusEndpoint
@EnableSpringBootMetricsCollector
public class Application {
public static void main(String[] args) { SpringApplication.run(Application.class, args);
}
}
最后,配置默認(rèn)的登錄賬號(hào)和密碼,在 application.yml 中:
security:
user:
name:user
password: pwd
啟動(dòng)應(yīng)用程序后,會(huì)看到如下一系列的 Mappings

利用賬號(hào)密碼訪問 http://localhost:8080/application/prometheus ,可以看到 Prometheus 格式的指標(biāo)數(shù)據(jù)

2、Prometheus 采集 Spring Boot 指標(biāo)數(shù)據(jù)
首先,獲取 Prometheus 的 Docker 鏡像:
$ docker pull prom/prometheus
然后,編寫配置文件 prometheus.yml :
global:
scrape_interval: 10s
scrape_timeout: 10s
evaluation_interval: 10m
scrape_configs:
- job_name: spring-boot
scrape_interval: 5s
scrape_timeout: 5s
metrics_path: /application/prometheus
scheme: http
basic_auth:
username: admin
password: 123456
static_configs:
- targets:
- 192.168.11.54:8099 #此處填寫 Spring Boot 應(yīng)用的 IP + 端口號(hào)
接著,啟動(dòng) Prometheus :
docker run -d --name prometheus -p 9090:9090 -v D:\test\actuator\prometheus\prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus
請(qǐng)注意,
D:\test\actuator\prometheus\prometheus.yml,是我的配置文件存放地址,我們需要將它放到容器里面去,所以用了-v來做文件映射。/etc/prometheus/prometheus.yml這個(gè)是容器啟動(dòng)的時(shí)候去取的默認(rèn)配置,這里我是直接覆蓋掉了它。prom/prometheus這是鏡像,如果本地沒有,就回去你設(shè)置好的鏡像倉(cāng)庫去取。
啟動(dòng)完成后用**docker ps**看下是否已經(jīng)啟動(dòng)成功,之后打開瀏覽器輸入:
http://localhost:9090/targets,檢查 Spring Boot 采集狀態(tài)是否正常,如果看到下圖就是成功了。

3、Grafana 可視化監(jiān)控?cái)?shù)據(jù)
首先,獲取 Grafana 的 Docker 鏡像:
$ docker pull grafana/grafana
然后,啟動(dòng) Grafana:
$ docker run --name grafana -d -p 3000:3000 grafana/grafana
接著,訪問 http://localhost:3000/ 配置 Prometheus 數(shù)據(jù)源:
Grafana 登錄賬號(hào) admin 密碼 admin
先配置數(shù)據(jù)源.

2.配置單個(gè)指標(biāo)的可視化監(jiān)控面板:



prometh采集的數(shù)據(jù)


到此這篇關(guān)于SpringBoot可視化監(jiān)控的具體應(yīng)用的文章就介紹到這了,更多相關(guān)SpringBoot可視化監(jiān)控內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- 使用SpringBoot+Prometheus+Grafana實(shí)現(xiàn)可視化監(jiān)控
- Spring?Boot?Admin?監(jiān)控指標(biāo)接入Grafana可視化的實(shí)例詳解
- vue+flv.js+SpringBoot+websocket實(shí)現(xiàn)視頻監(jiān)控與回放功能
- SpringBoot Admin 如何實(shí)現(xiàn)Actuator端點(diǎn)可視化監(jiān)控
- springboot Actuator的指標(biāo)監(jiān)控可視化功能詳解
- Springboot添加jvm監(jiān)控實(shí)現(xiàn)數(shù)據(jù)可視化
- SpringBoot監(jiān)視器的具體使用
相關(guān)文章
Java實(shí)現(xiàn)Fibonacci(斐波那契)取余的示例代碼
這篇文章主要介紹了Java實(shí)現(xiàn)Fibonacci取余的示例代碼,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-03-03
spring session同域下單點(diǎn)登錄實(shí)現(xiàn)解析
這篇文章主要介紹了spring session同域下單點(diǎn)登錄實(shí)現(xiàn)解析,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-10-10
springboot2.x實(shí)現(xiàn)oauth2授權(quán)碼登陸的方法
這篇文章主要介紹了springboot2.x實(shí)現(xiàn)oauth2授權(quán)碼登陸的方法,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-08-08
解決FeignClient發(fā)送post請(qǐng)求異常的問題
這篇文章主要介紹了FeignClient發(fā)送post請(qǐng)求異常的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2021-07-07

