栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

SpringBoot1.5X + prometheus+Grafana监控项目

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

SpringBoot1.5X + prometheus+Grafana监控项目

SpringBoot1.5X + prometheus+Grafana监控项目
由于项目比较老,使用的是springboot1.5x版本,所以以下的都是基于老版本项目监控,当前windows系统上本机运行

springboot1.5X 添加prometheus 插件 一、在pom.xml 添加jar包依赖
     
		org.springframework.boot
		spring-boot-starter-web
	
    
        io.micrometer
        micrometer-registry-prometheus
        1.1.4
    
    
        io.micrometer
        micrometer-spring-legacy
        1.1.4
    
二、在启动main方法里添加
@EnableAsync
@SpringBootApplication
public class EntinfotestApplication {

    public static void main(String[] args) {
        SpringApplication.run(EntinfotestApplication.class, args);
    }

    @Bean
    MeterRegistryCustomizer configurer(@Value("${spring.application.name}") String applicationName){
        return registry -> registry.config().commonTags("application", applicationName);
    }
 }   
三、在application.yml 里添加参数
#prometheus 监控插件
management:
  security:
    enabled: false
  endpoints:
    web:
      exposure:
        include: '*'
  metrics:
    tags:
      application: ${spring.application.name}
prometheus server 一、prometheus下载地址

https://prometheus.io/download/
可以根据具体操作系统下载对应的版本

二、下载之后解压文件,打开根目录下prometheus.yml配置文件,修改
global:
  scrape_interval: 15s  #默认抓取间隔, 15秒向目标抓取一次数据。
  evaluation_interval: 15s #触发告警检测的时间,15秒向目标抓取一次数据


scrape_configs: #这里表示抓取对象的配置
  - job_name: "prometheus" #prometheus 本机prometheus 的端口
    static_configs:
      - targets: ["localhost:9090"]    
  - job_name: "application"   
    metrics_path: '/prometheus'
    static_configs:
      - targets: ["localhost:8080"]   #监控项目名称  
三、 启动prometheus server

点击prometheus.exe 启动,访问localhost:9090 ,找到Status>>>> Targets

四、查看监控参数

点击自己监看的项目,

能看到 prometheus 监控的参数

点击Graph,复制prometheus 监控的参数,点击Execute 执行,就能看到监控图

Grafana 一、Grafana 官网下载地址

https://grafana.com/grafana/download/8.2.4?pg=get&plcmt=selfmanaged-box1-cta1&platform=windows
可以选择不同的版本和不同的环境进行下载

二、文件解压后,找到conf文件夹下 sample.ini,复制出一份命名为custom.ini

修改custom.ini里http_port = 9000

三、启动Grafana

找到bin目录下grafana-server.exe,点击启动

访问localhost:9000

grafana添加prometheus监控插件,按照步骤操作

选择需要添加的监控插件

设置Prometheus访问连接

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/583288.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号