springboot集成prometheus+grafana实现监控

软件准备

windows-prometheus(数据源):下载

windows-grafana(可视化):下载

linux-prometheus(数据源) : 下载

linux-grafana(可视化):下载

代码集成

pom依赖


    
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-registry-prometheus</artifactId>
			<version>1.6.4</version>
        </dependency>
        <!-- 解决包notfind问题 -->
        <dependency>
            <groupId>com.zaxxer</groupId>
            <artifactId>HikariCP</artifactId>
            <version>2.6.1</version>
            <exclusions>
                <exclusion>
                    <artifactId>slf4j-api</artifactId>
                    <groupId>org.slf4j</groupId>
                </exclusion>
            </exclusions>
        </dependency>

yaml配置

management:
  endpoints:
    web:
      exposure:
        #直接全部暴露,如果想部分的话多个之间用逗号隔开
        include: "*"
  metrics:
    tags:
      application: ${spring.application.name}

其他注意

如有权限框架如shiro,则需要开放接口

/actuator/**/** = anon

测试

http://localhost:8009/actuator

​​​​​​http://192.168.40.12:8009/actuator/prometheus

软件安装启动

windows

prometheus启动配置

修改prometheus.yml,增加自己项目配置

  - job_name: 'projectName'
    metrics_path: '/actuator/prometheus'
    static_configs:
    - targets: ['192.168.40.12:8009']

直接双击启动 && Linux 运行 ./prometheus &

 看见如下启动完成

 查看启动是否成功

http://localhost:9090/targets

grafana启动配置

直接双击启动&&Linux 进入bin 运行 ./grafana-server &

访问 localhost:3000,先添加数据源,这里的url为prometheus的地址
(默认账号密码:admin/admin )

 导入面板模板 

模板 json文件下载地址

JVM (Micrometer) dashboard for Grafana | Grafana Labs

(或者直接下载https://grafana.com/api/dashboards/4701/revisions/9/download

查看监控面板

 

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值