SpringBoot整合Prometheus 01
一、Prometheus整合
1、再pom檔案中新增如下配置
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
2、新增yum配置檔案
management:
server:
port: 11001
endpoints:
web:
exposure:
include: prometheus,health
3、在啟動類中新增入下程式碼,用於註冊統一tag名,便於查詢
方案1:新增配置檔案 (低版本沒tags屬性:譬如 2.0.9.RELEASE)
方案2:註冊程式碼
@Bean
MeterRegistryCustomizer<MeterRegistry> configurer(@Value("${spring.application.name}") String applicationName){
return registry -> registry.config().commonTags("application", applicationName);
}
4、啟動專案訪問:http://127.0.0.1:11001/actuator/prometheus
二、Prometheus監控
1、下載Prometheus
官網:https://prometheus.io/download/
地址:https://prometheus.io/download/prometheus-2.21.0.linux-amd64.tar.gz
2、 解壓並修改配置
修改 prometheus.yml
scrape_configs:
- job_name: 'prometheus-job1'
metrics_path: '/actuator/prometheus'
static_configs:
- targets: ['127.0.0.1:11001']
3、啟動Prometheus
./prometheus --config.file="prometheus.yml" &
4、訪問 http://192.168.158.200:9090/targets
三、配置Grafana 監控
1、 下載Grafana
官網:https://grafana.com/grafana/download?platform=linux
地址:https://dl.grafana.com/oss/release/grafana-7.1.5.linux-amd64.tar.gz
2、解壓啟動grafana
bin/grafana-server &
3、訪問 http://192.168.158.200:3000/
1)、新增Prometheus資料來源
2、新增監控DashBoard
1)新增監控 JVM 的 Dashboard ,匯入模板編號為 4701
1)新增自定panel,點選右上角新增新panel
以上!!!
PS:自定義dashboar的查詢條件需要在settings->Variables新增變數,
eg:
相關文章
- Prometheus 整合 Node ExporterPrometheusExport
- SpringBoot2.x整合Prometheus+Grafana【附原始碼+視訊】Spring BootPrometheusGrafana原始碼
- Spring Boot Actuator 整合 PrometheusSpring BootPrometheus
- asp.net core 整合 PrometheusASP.NETPrometheus
- SpringBoot使用prometheus監控Spring BootPrometheus
- SpringBoot整合系列-整合JPASpring Boot
- Probius+Prometheus通過API整合POD監控PrometheusAPI
- SpringBoot 整合 rabbitmqSpring BootMQ
- SpringBoot 整合 elkSpring Boot
- SpringBoot 整合 elasticsearchSpring BootElasticsearch
- SpringBoot 整合 apolloSpring Boot
- springboot整合redis?Spring BootRedis
- SpringBoot整合RedisSpring BootRedis
- flowable 整合 springbootSpring Boot
- SpringBoot整合MQTTSpring BootMQQT
- ElasticSearch 整合 SpringBootElasticsearchSpring Boot
- SpringBoot整合ESSpring Boot
- Springboot整合pagehelperSpring Boot
- springBoot整合thymeleafSpring Boot
- SpringBoot 整合 RedisSpring BootRedis
- SpringBoot整合NacosSpring Boot
- SpringBoot 整合 dockerSpring BootDocker
- Springboot整合RabbitMQSpring BootMQ
- springBoot整合flowableSpring Boot
- Springboot整合MyabitsSpring Boot
- springBoot 整合 mybatisSpring BootMyBatis
- SpringBoot整合elasticsearchSpring BootElasticsearch
- Springboot整合MybatisSpring BootMyBatis
- RocketMQ整合SpringBootMQSpring Boot
- 【SpringBoot】整合RedisSpring BootRedis
- springboot 整合jeagerSpring Boot
- SpringBoot整合DubboSpring Boot
- SpringBoot(19)---SpringBoot整合ApolloSpring Boot
- SpringBoot(17)---SpringBoot整合RocketMQSpring BootMQ
- SpringBoot(十六)_springboot整合JasperReSpring Boot
- SpringBoot整合系列-整合H2Spring Boot
- SpringBoot整合系列–整合MyBatis-plusSpring BootMyBatis
- Java服務端監控:Prometheus與Grafana的整合Java服務端PrometheusGrafana