自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Spring Boot 應(yīng)用可視化監(jiān)控

企業(yè)動(dòng)態(tài)
以下是Spring Boot 應(yīng)用可視化監(jiān)控,希望對(duì)大家學(xué)習(xí)有所幫助。

 [[247132]]

圖文簡(jiǎn)介

 

快速開始

1、Spring Boot 應(yīng)用暴露監(jiān)控指標(biāo)【版本 1.5.7.RELEASE】

首先,添加依賴如下依賴:

  1. <dependency> 
  2.            <groupId>org.springframework.boot</groupId> 
  3.            <artifactId>spring-boot-starter-actuator</artifactId> 
  4.        </dependency> 
  5.        <dependency> 
  6.            <groupId>io.prometheus</groupId> 
  7.            <artifactId>simpleclient_spring_boot</artifactId> 
  8.            <version>0.0.26</version> 
  9.        </dependency> 

然后,在啟動(dòng)類 Application.java 添加如下注解:

  1. @SpringBootApplication 
  2. @EnablePrometheusEndpoint 
  3. @EnableSpringBootMetricsCollector 
  4. public class Application { 
  5.    public static void main(String[] args) { 
  6.        SpringApplication.run(Application.class, args); 
  7.    } 

***,配置默認(rèn)的登錄賬號(hào)和密碼,在 application.yml 中:

  1. security: 
  2.  user
  3.    nameuser 
  4.    password: pwd 

提示:不建議配置 management.security.enabled:false啟動(dòng)應(yīng)用程序后,會(huì)看到如下一系列的 Mappings

 

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

 

2、Prometheus 采集 Spring Boot 指標(biāo)數(shù)據(jù)

首先,獲取 Prometheus 的 Docker 鏡像:

  1. $ docker pull prom/prometheus 

然后,編寫配置文件 prometheus.yml :

  1. global
  2.  scrape_interval: 10s 
  3.  scrape_timeout: 10s 
  4.  evaluation_interval: 10m 
  5. scrape_configs: 
  6.  - job_name: spring-boot 
  7.    scrape_interval: 5s 
  8.    scrape_timeout: 5s 
  9.    metrics_path: /application/prometheus 
  10.    scheme: http 
  11.    basic_auth: 
  12.      username: user 
  13.      password: pwd 
  14.    static_configs: 
  15.      - targets: 
  16.        - 127.0.0.1:8080  #此處填寫 Spring Boot 應(yīng)用的 IP + 端口號(hào) 

接著,啟動(dòng) Prometheus :

  1. $ docker run -d \ 
  2. --name prometheus \ 
  3. -p 9090:9090 \ 
  4. -m 500M \ 
  5. -v "$(pwd)/prometheus.yml":/prometheus.yml \ 
  6. -v "$(pwd)/data":/data \ 
  7. prom/prometheus \ 
  8. -config.file=/prometheus.yml \ 
  9. -log.level=info 

***,訪問(wèn) http://localhost:9090/targets , 檢查 Spring Boot 采集狀態(tài)是否正常。

 

3、Grafana 可視化監(jiān)控?cái)?shù)據(jù)

首先,獲取 Grafana 的 Docker 鏡像:

  1. $ docker pull grafana/grafana 

然后,啟動(dòng) Grafana:

  1. $ docker run --name grafana -d -p 3000:3000 grafana/grafana 

接著,訪問(wèn) http://localhost:3000/ 配置 Prometheus 數(shù)據(jù)源:

Grafana 登錄賬號(hào) admin 密碼 admin

 

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

 

提示,此處不能任意填寫,只能填已有的指標(biāo)點(diǎn),具體的可以在 Prometheus 的首頁(yè)看到,即 http://localhost:9090/graph

 

多配置幾個(gè)指標(biāo)之后,即可有如下效果:

 

參考文檔

  • prometheus 官方文檔
  • Grafana Docker 安裝
  • Spring Boot 官方文檔

【本文為51CTO專欄作者“李強(qiáng)強(qiáng)”的原創(chuàng)稿件,轉(zhuǎn)載請(qǐng)通過(guò)51CTO聯(lián)系作者獲取授權(quán)】

 

戳這里,看該作者更多好文

責(zé)任編輯:武曉燕 來(lái)源: 51CTO專欄
相關(guān)推薦

2009-04-21 14:26:41

可視化監(jiān)控IT管理摩卡

2023-02-07 07:03:39

2020-03-11 14:39:26

數(shù)據(jù)可視化地圖可視化地理信息

2020-03-01 14:01:22

Echarts數(shù)據(jù)可視化圖表

2021-09-26 16:20:04

Sentry Dashboards 數(shù)據(jù)可視化

2022-02-09 20:39:52

Actuator應(yīng)用監(jiān)控

2017-10-14 13:54:26

數(shù)據(jù)可視化數(shù)據(jù)信息可視化

2009-08-31 13:32:12

2022-08-26 09:15:58

Python可視化plotly

2010-06-17 17:56:57

世博IT監(jiān)控Rfid

2009-12-29 18:17:32

Silverlight

2023-12-27 18:05:13

2020-11-10 09:19:23

Spring BootJava開發(fā)

2021-02-03 12:47:09

Spring Boot應(yīng)用監(jiān)控

2021-01-21 05:32:26

云端視頻監(jiān)控

2023-04-14 08:21:55

2015-08-20 10:06:36

可視化

2022-04-15 11:32:20

IDE工具鴻蒙操作系統(tǒng)

2025-02-12 07:13:54

Knife4jAPISpringBoot

2023-09-19 21:09:40

可視化監(jiān)控Skywalking
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)