首页 > 解决方案 > 如何使用 SpringBoot 2、InfluxDB 和 Grafana 理解微米指标?

问题描述

我正在尝试配置 SpringBoot 应用程序以将指标导出到 InfluxDB 以使用 Grafana 仪表板将它们可视化。我以这个仪表板为例,它使用 Prometheus 作为后端。对于某些指标,我可以毫无问题地弄清楚如何为它们创建图表,但对于其他一些指标,我不知道如何创建图表,甚至根本不知道如何创建图表。因此,我在以下几点中列举了我不太确定的事情:

作为我插入 InfluxDB 的措施示例:

time                 count exception mean     method metric_type outcome status sum      upper    uri
1625579637946000000  1     None      0.892144 GET    histogram   SUCCESS 200    0.892144 0.892144 /actuator/health

或者

time                action          cause                 count   mean  metric_type  sum upper
1625581132316000000 end of minor    GC Allocation Failure     1      2  histogram    2   2

标签: grafanainfluxdbmetricsspring-micrometer

解决方案


我同意千分尺的文档不是很好。我不得不挖掘代码以找到答案......

关于您关于jvm_gc_pause的问题,它是一个Timer,实现是AbstractTimer一个包含Histogram其他组件的类。该特定指标由JvmGcMetrics类注册。发布到 InfluxDB 的各种测量值由以下InfluxMeterRegistry.writeTimer(Timer timer)方法确定:

  • 和:timer.totalTime(getBaseTimeUnit()) // The total time of recorded events
  • 数数:timer.count() // The number of times stop has been called on the timer
  • 意思是:timer.mean(getBaseTimeUnit()) // totalTime()/count()
  • 上:timer.max(getBaseTimeUnit()) // The max time of a single event

基本时间单位是毫秒。

同样,http_server_requests似乎也是一个Timer

我相信你是对的,明智的做法是在两个单独的 Grafana 面板上绘制图表:一个面板用于 GC 暂停秒使用sum(或meanupper),另一个面板用于 GC 事件使用count.


推荐阅读