graphite - Spring Boot Micrometer 分层度量命名空间串联
问题描述
我有一个 Spring Boot Java 应用程序,并且正在将指标发送到分层 Graphite 指标系统。我正在使用 management.metrics.export.graphite.tags-as-prefix 并映射主机和应用程序来为我的指标添加前缀。然后我有一个带有命名空间jvm.memory.committed
的度量,但度量命名空间是作为host.app.jvmMemoryCommitted.*
. 所以它正在替换度量命名空间中的点(“.”),并替换命名空间的以下部分。
应用程序属性
management.metrics.export.graphite.tags-as-prefix=[host, app]
标签的定制器作为前缀。
@Bean
public MeterRegistryCustomizer<MeterRegistry> commonTags() {
return r -> r.config().commonTags("host", "localhost", "app", "app");
}
当我查看 .../actuator/metrics/jvm.memory.committed 端点时,我看到以下内容:
"name": "jvm.memory.committed",
"description": "The amount of memory in bytes that is committed for the Java virtual machine to use",
"baseUnit": "bytes",
"measurements": [
{
"statistic": "VALUE",
"value": 759701504
}
],
"availableTags": [
{
"tag": "area",
"values": [
"heap",
"nonheap"
]
},
{
"tag": "app",
"values": [
"app"
]
},
{
"tag": "host",
"values": [
"localhost"
]
},
{
"tag": "id",
"values": [
"G1 Old Gen",
"CodeHeap 'non-profiled nmethods'",
"G1 Survivor Space",
"Compressed Class Space",
"Metaspace",
"G1 Eden Space",
"CodeHeap 'non-nmethods'"
]
},
]
}
但是,当发送指标时,指标名称从 更改*.jvm.memory.committed.*
为*.jvmMemoryCommitted.*
。如何以点表示法保留指标命名空间?
请参阅下面的 tcpdump 输出:
$ sudo tcpdump -i any -A -s0 -vv udp port 2003 | grep -i committed
tcpdump: data link type PKTAP
tcpdump: listening on any, link-type PKTAP (Apple DLT_PKTAP), capture size 262144 bytes
....E....5..@............E...p..localhost.app.jvmMemoryCommitted.area.heap.id.G1_Eden_Space 178257920.00 1628102627
....E....5..@............E...p..localhost.app.jvmMemoryCommitted.area.heap.id.G1_Eden_Space 178257920.00 1628102627
....E...o...@............E...m..localhost.app.jvmMemoryCommitted.area.heap.id.G1_Old_Gen 465567744.00 1628102627
....E...o...@............E...m..localhost.app.jvmMemoryCommitted.area.heap.id.G1_Old_Gen 465567744.00 1628102627
....E.......@............E...s..localhost.app.jvmMemoryCommitted.area.heap.id.G1_Survivor_Space 10485760.00 1628102627
....E.......@............E...s..localhost.app.jvmMemoryCommitted.area.heap.id.G1_Survivor_Space 10485760.00 1628102627
....E...m...@............E...{..localhost.app.jvmMemoryCommitted.area.nonheap.id.CodeHeap_'non-nmethods' 3604480.00 1628102627
....E...m...@............E...{..localhost.app.jvmMemoryCommitted.area.nonheap.id.CodeHeap_'non-nmethods' 3604480.00 1628102627
....E....J..@............E......localhost.app.jvmMemoryCommitted.area.nonheap.id.CodeHeap_'non-profiled_nmethods' 10420224.00 1628102627
....E....J..@............E......localhost.app.jvmMemoryCommitted.area.nonheap.id.CodeHeap_'non-profiled_nmethods' 10420224.00 1628102627
....E.......@............E...z..localhost.app.jvmMemoryCommitted.area.nonheap.id.Compressed_Class_Space 9306112.00 1628102627
....E.......@............E...z..localhost.app.jvmMemoryCommitted.area.nonheap.id.Compressed_Class_Space 9306112.00 1628102627
....E....,..@............E...n..localhost.app.jvmMemoryCommitted.area.nonheap.id.Metaspace 69607424.00 1628102627
....E....,..@............E...n..localhost.app.jvmMemoryCommitted.area.nonheap.id.Metaspace 69607424.00 1628102627
^C444 packets captured
3200 packets received by filter
0 packets dropped by kernel```
I think the problem is that I'm using tags, but in a Hierarchical metrics system, but I can't figure out how to configure it properly. I can't seem to find my folly.
Spring Boot 2.5.2
Micrometer Core and Micrometer Registry Graphite 1.7.2
解决方案
Graphite 使用 aHierarchicalNameMapper
将指标名称和标签转换为分层字符串。
见https://micrometer.io/docs/registry/graphite#_hierarchical_name_mapping
我不确定为什么您的映射器使用驼峰式命名您的指标名称,但是您可以HierarchicalNameMapper
在构建自己的指标名称时进行设置,GraphiteMeterRegistry
并对它们的生成方式进行微调控制。
推荐阅读
- spring - Spring Batch RabbitMQ 问题
- php - 如何对具有实时搜索功能的表进行分页?
- python-3.x - 使用带有方法的 python `eval()`
- c# - 使用递归创建一个程序,该程序将数组中的奇数作为特定格式的字符串返回 c#
- python - Python分割线并将其写入文件
- java - 从Java中的国家代码获取默认语言
- java - 如何为特定任务启动一个线程并在 Java 中运行最多 5 秒?
- blazor - Blazor:有条件地显示 RenderFragment 组件
- flutter - Flutter 字体管理
- c# - 如何保持光线投射相对于其绑定的对象?