繁体   English   中英

Prometheus-Grafana:如何在查询中使用通配符

[英]Prometheus-Grafana : How to use wildcard in query

我在普罗米修斯中有以下标签,如何在模板化“查询”之类的内容时创建通配符查询:“label_values(application_*Count_Total,xyx)”。 这些值是从 Eclipse Microprofile REST-API 生成的

application_getEnvVariablesCount_total
application_getFEPmemberCount_total
application_getLOBDetailsCount_total
application_getPropertiesCount_total
  {
    "allValue": null,
    "current": {
      "isNone": true,
      "selected": false,
      "text": "None",
      "value": ""
    },
    "datasource": "bcnc-prometheus",
    "definition": "microprofile1",
    "hide": 0,
    "includeAll": false,
    "label": null,
    "multi": false,
    "name": "newtest",
    "options": [
      {
        "isNone": true,
        "selected": true,
        "text": "None",
        "value": ""
      }
    ],
    "query": "microprofile1",
    "refresh": 0,
    "regex": "{__name__=~\"application_.*Count_total\"}",
    "skipUrlSync": false,
    "sort": 0,
    "tagValuesQuery": "",
    "tags": [],
    "tagsQuery": "",
    "type": "query",
    "useTags": false
  },

Prometheus 以与具有特殊标签__name__标签值相同的方式处理指标名称。 因此,以下查询应选择名称与application_.*Count_total regexp 匹配的度量标准中标签xyx所有值:

label_values({__name__=~"application_.*Count_total"}, xyx)

在我的 Promql 中,这对我有用:

topk(5, {__name__=~"thing_you_want_to_search.*"})

它找到与thing_you_want_to_search*匹配的前 5 行

@valyala,我得到了它

"query": "metrics(application_get.*Count_total)",
"regex": "/application_get(.*)Count_total/",

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM