Merge up status and instance_name panel

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

    Grafana v12.2.1 (563109b696)

  • What are you trying to achieve?
    I am trying to merge the results of 2 prometheus metrics, up and server_name into one panel per node.The panel should include both the server name and ip address. The panel should be green if the node is up and red if the node is down.

  • How are you trying to achieve it?
    I have tried joining by field, but there is no option to select the instance ip address, a value both queries have in common.

  • What happened?
    The server_name is in a different panel to the one holding the ip address and up status.

  • What did you expect to happen?
    For there to be a single panel to represent the node, containing both the name, ip address and colour reflecting the up status as pictured in this photoshopped output below.

  • Can you copy/paste the configuration(s) that you are having problems with?
    Panel JSON:

{
  "id": 1,
  "type": "stat",
  "title": "New panel",
  "gridPos": {
    "x": 0,
    "y": 0,
    "h": 8,
    "w": 12
  },
  "fieldConfig": {
    "defaults": {
      "mappings": [],
      "thresholds": {
        "mode": "absolute",
        "steps": [
          {
            "color": "green",
            "value": null
          },
          {
            "color": "red",
            "value": 80
          }
        ]
      },
      "unit": "short"
    },
    "overrides": []
  },
  "transformations": [
    {
      "id": "joinByField",
      "options": {
        "byField": "Time",
        "mode": "outerTabular"
      }
    }
  ],
  "pluginVersion": "12.2.1",
  "targets": [
    {
      "datasource": {
        "type": "prometheus",
        "uid": "ff33tt81bqs5cc"
      },
      "editorMode": "builder",
      "expr": "up",
      "legendFormat": "{{instance}}",
      "range": true,
      "refId": "A"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "ff33tt81bqs5cc"
      },
      "editorMode": "builder",
      "expr": "server_name",
      "hide": false,
      "instant": false,
      "legendFormat": "{{instance_name}}",
      "range": true,
      "refId": "B"
    }
  ],
  "datasource": {
    "type": "prometheus",
    "uid": "ff33tt81bqs5cc"
  },
  "options": {
    "reduceOptions": {
      "values": false,
      "calcs": [
        "lastNotNull"
      ],
      "fields": ""
    },
    "orientation": "auto",
    "textMode": "name",
    "wideLayout": true,
    "colorMode": "background",
    "graphMode": "none",
    "justifyMode": "auto",
    "showPercentChange": false,
    "percentChangeColorMode": "standard"
  }
}

One possible way is using the new public preview SQL Expression