一键集成prometheus监控微服务接口平均响应时长

一、效果展示

在这里插入图片描述

二、环境准备

prometheus + grafana环境
参考博文:https://blog.csdn.net/luckywuxn/article/details/129475991

三、导入依赖

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

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>
        
        <dependency>
            <groupId>cn.strongculture</groupId>
            <artifactId>prometheus-spring-boot-starter</artifactId>
            <version>1.0.0</version>
        </dependency>

三、添加配置

## Actuator
management.endpoints.web.exposure.include=*
management.metrics.tags.application=${spring.application.name}
monitor.api.pointcut.expression=execution(public * com.strongculture.prometheusstartertest..*.*(..))
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
监控磁盘IO平均响应时间,可以使用Prometheus的Node Exporter来收集磁盘相关的指标数据。Node Exporter是一个开源的工具,可以用于收集Linux系统的各种指标数据,如CPU、内存、磁盘IO等。 以下是一些可以用于监控磁盘IO平均响应时间Prometheus查询: 1. 磁盘IO平均响应时间: ``` avg(irate(node_disk_write_time_seconds_total[1m]) + irate(node_disk_read_time_seconds_total[1m])) ``` 该查询将磁盘读写时间指标的1分钟速率(irate),即每秒的平均值,相加并除以2,以计算平均响应时间。 2. 磁盘IO平均等待时间: ``` avg(irate(node_disk_io_time_seconds_total[1m])) ``` 该查询将磁盘IO时间指标的1分钟速率(irate),即每秒的平均值,计算出磁盘IO的平均等待时间。 3. 磁盘IO错误率: ``` sum(rate(node_disk_io_time_seconds_total{device=~"$device"}[5m])) by (device) / sum(rate(node_disk_io_time_seconds_total[5m])) by (device) ``` 该查询将磁盘IO时间指标的5分钟速率(rate)按设备(device)分组,然后计算每个设备的磁盘IO错误率。 以上查询需要在PromQL中使用,可以在Prometheus的Web界面或Grafana中执行。要收集这些指标,需要在Node Exporter的配置文件中启用相应的收集器。例如,要启用磁盘IO时间指标收集器,需要在Node Exporter的配置文件中添加以下行: ``` - collector.textfile.directory=/var/lib/node_exporter/textfile_collector - collector.diskstats - collector.filesystem ``` 其中collector.diskstats和collector.filesystem是启用磁盘IO时间指标收集器的配置项,collector.textfile.directory是用于存储自定义指标的目录。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

道法自然 实事求是

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值