Grafana 和 Prometheus:从 job_name 获取目标

Grafana & Prometheus: get target from a job_name

我需要在 grafana 的仪表板中从特定 job_name(activemq-job)中获取目标列表(activemq01、activemq02、activemq03)。

实际上,我只能在我的仪表板上获取 job_name,但我无法按目标进行过滤。

Prometheus.yaml

  - job_name: activemq-job
    static_configs:
    - targets: ['activemq01:8060', 'activemq02:8060', 'activemq03:8060']

Dashboard.json

      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_PROMETHEUS}",
        "definition": "label_values(job)",
        "hide": 0,
        "includeAll": true,
        "index": -1,
        "label": null,
        "multi": true,
        "name": "Component",
        "options": [],
        "query": "label_values(job)",
        "refresh": 2,
        "regex": "(activemq-job)",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },

在变量定义中使用以下内容:

Query = label_values(instance)