Grafana Prometheus Multiple Queries One Table

  • What Grafana version and what operating system are you using?

    • Grafana v11.6.1
  • What are you trying to achieve?

    • Show multiple queries in table visual grouped by instance name
  • How are you trying to achieve it?

    • I am testing with 2 queries, 1 that pulls upsBatteryStatus and 1 that pulls upsAlarmsPresent
    • These are time series values and I simply want a table that shows instances on the left, and a column for each query value
    • For example, left column would show upsA and upsB,next column would be the upsBatteryStatus and next column would be upsAlarmsPresent
  • What happened?

    • I am getting all kinds of strange groupings or no data being shown
    • I have tried different combinations of trasnformations (group-by, concatenate-field, reduce to get last value)
  • Can you copy/paste the configuration(s) that you are having problems with?

{
  "id": 13,
  "type": "table",
  "title": "Panel Title",
  "gridPos": {
    "x": 0,
    "y": 0,
    "h": 8,
    "w": 12
  },
  "fieldConfig": {
    "defaults": {
      "custom": {
        "align": "auto",
        "cellOptions": {
          "type": "auto"
        },
        "inspect": false
      },
      "mappings": [],
      "thresholds": {
        "mode": "absolute",
        "steps": [
          {
            "value": null,
            "color": "green"
          },
          {
            "value": 80,
            "color": "red"
          }
        ]
      },
      "color": {
        "mode": "thresholds"
      }
    },
    "overrides": []
  },
  "pluginVersion": "11.6.1",
  "targets": [
    {
      "refId": "A",
      "editorMode": "builder",
      "expr": "upsBatteryStatus",
      "legendFormat": "{{instance}}",
      "range": true,
      "useBackend": false,
      "disableTextWrap": false,
      "fullMetaSearch": false,
      "includeNullMetadata": true
    },
    {
      "refId": "B",
      "expr": "upsAlarmsPresent",
      "range": true,
      "instant": false,
      "datasource": {
        "uid": "deki76rdyjpxce",
        "type": "prometheus"
      },
      "hide": false,
      "editorMode": "builder",
      "legendFormat": "{{instance}}",
      "useBackend": false,
      "disableTextWrap": false,
      "fullMetaSearch": false,
      "includeNullMetadata": true
    }
  ],
  "datasource": {
    "uid": "deki76rdyjpxce",
    "type": "prometheus"
  },
  "options": {
    "showHeader": true,
    "cellHeight": "sm",
    "footer": {
      "show": false,
      "reducer": [
        "sum"
      ],
      "countRows": false,
      "fields": ""
    },
    "frameIndex": 0
  }
}
1 Like

Follow the detailed steps
Step 1: Create table and insert data in table


Step 2: Add datasource and write query to display data on panel

Thank you for the respose.
I am able to follow your steps.
However, I am wanting to see the last value and the left column should be instance.
So that if I have 20 different instance to monitor I can see their last values across the table.


please confirm this is your requirement , if this you can use group by transformation to achive this.