内射老阿姨1区2区3区4区_久久精品人人做人人爽电影蜜月_久久国产精品亚洲77777_99精品又大又爽又粗少妇毛片

SpringBoot使用prometheus監(jiān)控

1.關(guān)于Prometheus
Prometheus是一個根據(jù)應(yīng)用的metrics來進行監(jiān)控的開源工具。相信很多工程都在使用它來進行監(jiān)控,有關(guān)詳細介紹可以查看官網(wǎng):https://prometheus.io/docs/introduction/overview/。
2.有關(guān)Grafana
Grafana是一個開源監(jiān)控利器,如圖所示。

10年積累的成都做網(wǎng)站、成都網(wǎng)站建設(shè)經(jīng)驗,可以快速應(yīng)對客戶對網(wǎng)站的新想法和需求。提供各種問題對應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認識你,你也不認識我。但先網(wǎng)站設(shè)計后付款的網(wǎng)站建設(shè)流程,更有上黨免費網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。

SpringBoot使用prometheus監(jiān)控

從圖中就可以看出來,使用Grafana監(jiān)控很高大上,提供了很多可視化的圖標(biāo)。
官網(wǎng)地址:https://grafana.com/
3.SpringBoot使用Prometheus
3.1 依賴內(nèi)容
在SpringBoot中使用Prometheus其實很簡單,不需要配置太多的東西,在pom文件中加入依賴,完整內(nèi)容如下所示。

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.3.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.dalaoyang</groupId>
    <artifactId>springboot2_prometheus</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>springboot2_prometheus</name>
    <description>springboot2_prometheus</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-registry-prometheus</artifactId>
            <version>1.1.3</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

3.2 配置文件
配置文件中加入配置,這里就只進行一些簡單配置,management.metrics.tags.application屬性是本文配合Grafana的Dashboard設(shè)置的,如下所示:

spring.application.name=springboot_prometheus
management.endpoints.web.exposure.include=*
management.metrics.tags.application=${spring.application.name}

3.3 設(shè)置application
修改啟動類,如下所示.

@SpringBootApplication
public class Springboot2PrometheusApplication {

    public static void main(String[] args) {
        SpringApplication.run(Springboot2PrometheusApplication.class, args);
    }
    @Bean
    MeterRegistryCustomizer<MeterRegistry> configurer(
            @Value("${spring.application.name}") String applicationName) {
        return (registry) -> registry.config().commonTags("application", applicationName);
    }
}

SpringBoot項目到這里就配置完成了,啟動項目,訪問http://localhost:8080/actuator/prometheus,如圖所示,可以看到一些度量指標(biāo)。
SpringBoot使用prometheus監(jiān)控
4.Prometheus配置
4.1 配置應(yīng)用
在prometheus配置監(jiān)控我們的SpringBoot應(yīng)用,完整配置如下所示。

# my global config
global:
  scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).

# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    - targets:
      # - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  - job_name: 'prometheus'
    static_configs:
    - targets: ['127.0.0.1:9090']
###以下內(nèi)容為SpringBoot應(yīng)用配置
  - job_name: 'springboot_prometheus'
    scrape_interval: 5s
    metrics_path: '/actuator/prometheus'
    static_configs:
      - targets: ['127.0.0.1:8080']

4.2 啟動Prometheus
啟動Prometheus,瀏覽器訪問,查看Prometheus頁面,如圖所示。
SpringBoot使用prometheus監(jiān)控
點擊如圖所示位置,可以查看Prometheus監(jiān)控的應(yīng)用。

SpringBoot使用prometheus監(jiān)控
列表中UP的頁面為存活的實例,如圖所示。
SpringBoot使用prometheus監(jiān)控
也可以查看很多指數(shù),如下所示。
SpringBoot使用prometheus監(jiān)控
5.Grafana配置
啟動Grafana,配置Prometheus數(shù)據(jù)源,這里以ID是4701的Doshboard為例(地址:https://grafana.com/dashboards/4701)如圖。
SpringBoot使用prometheus監(jiān)控
在Grafana內(nèi)點擊如圖所示import按鈕
SpringBoot使用prometheus監(jiān)控
在如圖所示位置填寫4701,然后點擊load。
SpringBoot使用prometheus監(jiān)控
接下來導(dǎo)入Doshboard。
SpringBoot使用prometheus監(jiān)控
導(dǎo)入后就可以看到我們的SpringBoot項目對應(yīng)的指標(biāo)圖表了,如圖。
SpringBoot使用prometheus監(jiān)控
6.源碼
源碼地址:https://gitee.com/dalaoyang/springboot_learn/tree/master/springboot2_prometheus

網(wǎng)頁題目:SpringBoot使用prometheus監(jiān)控
URL標(biāo)題:http://www.rwnh.cn/article16/jjssdg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站營銷、品牌網(wǎng)站制作、Google、手機網(wǎng)站建設(shè)、網(wǎng)站內(nèi)鏈定制網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)
当涂县| 苗栗市| 棋牌| 河北省| 都昌县| 都兰县| 棋牌| 苗栗县| 建平县| 望谟县| 东乡族自治县| 深圳市| 宕昌县| 理塘县| 调兵山市| 克拉玛依市| 广灵县| 卢湾区| 福泉市| 尉犁县| 五莲县| 米易县| 富顺县| 增城市| 寻乌县| 井冈山市| 浏阳市| 高邮市| 明溪县| 得荣县| 泰州市| 泰兴市| 湟源县| 凤凰县| 鄱阳县| 西林县| 东辽县| 安徽省| 象州县| 灵璧县| 黄龙县|