grafana - 如何使用 SpringBoot 2、InfluxDB 和 Grafana 理解微米指标?
问题描述
我正在尝试配置 SpringBoot 应用程序以将指标导出到 InfluxDB 以使用 Grafana 仪表板将它们可视化。我以这个仪表板为例,它使用 Prometheus 作为后端。对于某些指标,我可以毫无问题地弄清楚如何为它们创建图表,但对于其他一些指标,我不知道如何创建图表,甚至根本不知道如何创建图表。因此,我在以下几点中列举了我不太确定的事情:
是否有描述价值单位的文档?我用作示例的应用程序没有任何负载,所以有时我不知道该值是位、字节、秒、毫秒、计数等。
一些测量包含标签“metric_type = histogram”,字段为“count”、“sum”、“mean”和“upper”。同样,在这里我不知道价值单位是什么,上限是什么意思或我想如何绘制它们。例如“http_server_requests”或“jvm_gc_pause”。
从我在 Grafana 仪表板示例中看到的内容来看,似乎我应该使用这些直方图类型的度量来创建具有计数的图形和具有持续时间的图形。例如,我看到我应该能够创建一个包含请求数量的图表和另一个包含其持续时间的图表。或者对于垃圾收集器,我应该能够提供一个关于次要和主要 GC 数量的图表以及另一个关于它们持续时间的图表。
作为我插入 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
解决方案
我同意千分尺的文档不是很好。我不得不挖掘代码以找到答案......
关于您关于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
(或mean
或upper
),另一个面板用于 GC 事件使用count
.
推荐阅读
- statistics - 为什么可以从数据集中删除具有低方差的变量
- python - 如何添加两个字符串数字(带浮点)?
- python - 获取所有帧中像素的平均值
- javascript - 如何获得4位数字的最小可能组合
- sql - 如何根据同一查询中的第二个不同列计算值?
- dom - 如何使用转译器设置 Jest,以便我可以自动模拟 DOM 和画布?
- c# - 如何在 Azure DevOps 上为发布服务器项目而不是客户端的 Blazor WebAssembly 托管应用程序创建构建管道?
- r - 条形图 - R 中的直方图
- php - php,如何将 int 打包为签名的 64 位 little-endian 字符串?
- json - 字符串列表的 Spring Boot 输入验证仅返回第一个无效值