按名称堆叠/重叠指标

时间:2018-09-13 12:34:19

标签: jmx grafana prometheus

我有一个通过micrometer-jmx进行prometheus传递的应用程序度量标准,我无法将应用程序更改为使用micrometer-prometheus。因此,所有参数化指标都不是普罗米修斯标签,而是直接编码为指标名称。

即指标以requests_Count{processor="BILLING_PROCESSOR", type="SCRIPT"}的形式代替requests_PRC_BILLING_PROCESSOR_TYP_SCRIPT_Count

现在,让我们说我想在grafana中按类型对请求计数进行分组(堆叠/重叠)的图形。没有标签和采用这种格式的指标,我有什么方法可以做到这一点?我设法构造了grafana变量,该变量从度量标准名称中提取处理器并键入值,但是我似乎对这些值没有太大作用。

1 个答案:

答案 0 :(得分:1)

您可以配置Prometheus来转换度量标准名称。这是Prometheus中重新标记的一部分。在Prometheus Configurationblog post by one of the core contributors中进行了描述。

从博客文章中提取的指标可以从

转换
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__