<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>

          快來(lái)試試 Spring Boot 應(yīng)用可視化監(jiān)控,一目了然!

          共 2388字,需瀏覽 5分鐘

           ·

          2021-05-25 21:19

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

          首先,添加依賴(lài)如下依賴(lài):

          <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)類(lèi) Application.java 添加如下注解:

          @SpringBootApplication@EnablePrometheusEndpoint@EnableSpringBootMetricsCollectorpublic 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

          img

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


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

          首先,獲取 Prometheus 的 Docker 鏡像:

          $ docker pull prom/prometheus

          然后,編寫(xiě)配置文件 prometheus.yml :

          global:  scrape_interval: 10s  scrape_timeout: 10s  evaluation_interval: 10mscrape_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 #此處填寫(xiě) 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來(lái)做文件映射。/etc/prometheus/prometheus.yml這個(gè)是容器啟動(dòng)的時(shí)候去取的默認(rèn)配置,這里我是直接覆蓋掉了它。prom/prometheus這是鏡像,如果本地沒(méi)有,就回去你設(shè)置好的鏡像倉(cāng)庫(kù)去取。

          啟動(dòng)完成后用docker ps看下是否已經(jīng)啟動(dòng)成功,之后打開(kāi)瀏覽器輸入:
          http://localhost:9090/targets,檢查 Spring Boot 采集狀態(tài)是否正常,如果看到下圖就是成功了。

          img

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

          首先,獲取 Grafana 的 Docker 鏡像:

          $ docker pull grafana/grafana1

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

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

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

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

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

          img

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

          img

          img

          img

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

          img

          img

          最近給大家找了  百萬(wàn)級(jí)電商


          資源,怎么領(lǐng)???


          掃二維碼,加我微信,回復(fù):百萬(wàn)級(jí)電商

           注意,不要亂回復(fù) 

          沒(méi)錯(cuò),不是機(jī)器人
          記得一定要等待,等待才有好東西


          瀏覽 57
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          <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>
                  欧美三级片免费网站 | 日本三级视频中文字幕 | 欧美性爱乱伦 | 豆花无码在线 | 国产精品酒店 |