jmx - 按名称堆叠/重叠指标
问题描述
我有一个通过 micrometer-jmx 向 prometheus 发送指标的应用程序,我无法将应用程序更改为使用 micrometer-prometheus。因此,所有参数化指标都不是普罗米修斯标签,而是直接编码到指标名称中。
即,而不是requests_Count{processor="BILLING_PROCESSOR", type="SCRIPT"}
指标的形式是requests_PRC_BILLING_PROCESSOR_TYP_SCRIPT_Count
。
现在假设我想要一个按类型分组(堆叠/重叠)的请求计数的 grafana 图表。有没有什么方法可以在没有标签和这种格式的指标的情况下完成?我已经设法构建了 grafana 变量,这些变量从指标名称中提取处理器和类型值,但我似乎对这些值无能为力。
解决方案
您可以配置 Prometheus 来转换指标名称。这是 Prometheus 中可用的重新标记的一部分。它在Prometheus 配置和核心贡献者之一的博客文章中进行了描述。
从博客文章中提取的指标可以从
memory_pools_PS_Eden_Space_committed
至
memory_pools_committed_bytes{pool="PS_Eden_Space"}
通过应用如下配置:
scrape_configs:
job_name: my_job
# Usual fields go here to specify targets.
metric_relabel_configs:
- source_labels: [__name__]
regex: '(memory_pools)_(.*)_(\w+)'
replacement: '${2}'
target_label: pool
- source_labels: [__name__]
regex: '(memory_pools)_(.*)_(\w+)'
replacement: '${1}_${3}_bytes'
target_label: __name__
推荐阅读
- r - 如何确定 Jenks Natural Breaks 中的最佳聚类数
- django - 如何在同一模型中存储多个用户标识?
- javascript - CkEditor 4 自定义行高不工作
- javascript - 在 JavaScript 中对对象数组的特定值运行自定义函数的最佳实践是什么?
- reactjs - 使用 Material UI 在 Reactjs 中传递数据
- c++ - 如何在 C++ 中为双向链表编写 setter 和 getter
- r - 如何在R中显示堆栈跟踪而没有错误?
- vbscript - 我可以通过全局脚本消除 VBS 重复代码吗?
- angular - Angular Material:为什么控制颜色会反转?
- java - 如何将字符串中等式的这些元素分离为所需的格式?