<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          Spring Boot 應(yīng)用可視化監(jiān)控,一目了然!

          共 3385字,需瀏覽 7分鐘

           ·

          2021-06-07 01:59

          上一篇:一個90后員工猝死的全過程


          1、Spring Boot 應(yīng)用暴露監(jiān)控指標(biāo)

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

          <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>
          然后,在啟動類 Application.java 添加如下注解:
          @SpringBootApplication
          @EnablePrometheusEndpoint
          @EnableSpringBootMetricsCollector
          public class Application {  
              public static void main(String[] args) {
               SpringApplication.run(Application.class, args); 
              }
          }
          最后,配置默認(rèn)的登錄賬號和密碼,在 application.yml 中:
          security:
            user:
              name:user
              password: pwd

          啟動應(yīng)用程序后,會看到如下一系列的 Mappings

          利用賬號密碼訪問 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 + 端口號

          接著,啟動 Prometheus :

          docker run -d --name prometheus -p 9090:9090
          -v D:\test\actuator\prometheus\prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus

          3、Grafana 可視化監(jiān)控數(shù)據(jù)

          首先,獲取 Grafana 的 Docker 鏡像:

          $ docker pull grafana/grafana1

          然后,啟動 Grafana:

          $ docker run --name grafana -d -p 3000:3000 grafana/grafana1

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

          Grafana 登錄賬號 admin 密碼 admin

          1. 先配置數(shù)據(jù)源.

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

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

          參考:https://www.jianshu.com/p/7ecb57a3f326
          原文:https://blog.csdn.net/weixin_44196699/article/details/105010045



          最后,關(guān)注公眾號互聯(lián)網(wǎng)架構(gòu)師,在后臺回復(fù):2T,可以獲取我整理和創(chuàng)作的 Java 系列教程非常齊全。

           推薦閱讀 

          1、2019 年 9 月全國程序員工資統(tǒng)計,你是什么水平?

          2、如何才能成為優(yōu)秀的架構(gòu)師?

          3、從零開始搭建創(chuàng)業(yè)公司后臺技術(shù)棧

          4、程序員一般可以從什么平臺接私活?

          5、37歲程序員被裁,120天沒找到工作,無奈去小公司,結(jié)果懵了...

          6、滴滴業(yè)務(wù)中臺構(gòu)建實(shí)踐,首次曝光

          7、不認(rèn)命,從10年流水線工人,到谷歌上班的程序媛,一位湖南妹子的勵志故事

          8、15張圖看懂瞎忙和高效的區(qū)別!


          瀏覽 13
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報
          評論
          圖片
          表情
          推薦
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  亚洲啪啪网 | 欧美A片黄色 | 18 网站视频 | 嫩逼网| 色五月婷婷丁香综合 |