Grafana dashboard: Slurm Cgroups
Description: Metrics collected by the cgroups_exporter.

This dashboard visualizes data collected by the Prometheus [cgroups_exporter](https://github.com/phpHavok/cgroups_exporter) running in Slurm mode on an High Performance Computing (HPC) cluster that utilizes the [Slurm](https://slurm.schedmd.com/) scheduler configured with `TaskPlugin=task/cgroup`. The dashboard visualizes per-node metrics at the job-level for jobs that run across multiple nodes in a cluster.

Metrics include:
- **Per-CPU usage:** When there are multiple jobs running on a single node, this dashboard visualizes only CPUs utilized by a given job on that node.
- **Total CPU usage:** Shows the total CPU utilization for only those CPUs scheduled to your job on each node.
- **Memory usage:** Likewise, this dashboard visualizes the memory utilized by only a given job, even if multiple jobs ran on the same node and utilized memory.

{
  "__inputs": [],
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "8.0.1"
    },
    {
      "type": "panel",
      "id": "graph",
      "name": "Graph (old)",
      "version": ""
    },
    {
      "type": "datasource",
      "id": "prometheus",
      "name": "Prometheus",
      "version": "1.0.0"
    },
    {
      "type": "panel",
      "id": "stat",
      "name": "Stat",
      "version": ""
    }
  ],
  "annotations": {
    "list": [
      {
        "$$hashKey": "object:886",
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "description": "Metrics collected by the cgroups_exporter.",
  "editable": true,
  "gnetId": 14587,
  "graphTooltip": 0,
  "id": null,
  "iteration": 1625236157484,
  "links": [],
  "panels": [
    {
      "collapsed": false,
      "datasource": null,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "id": 14,
      "panels": [],
      "repeat": "node",
      "title": "$node",
      "type": "row"
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "$prom_ds",
      "description": "",
      "fieldConfig": {
        "defaults": {
          "links": []
        },
        "overrides": []
      },
      "fill": 1,
      "fillGradient": 0,
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 1
      },
      "hiddenSeries": false,
      "id": 11,
      "interval": "",
      "legend": {
        "alignAsTable": false,
        "avg": false,
        "current": false,
        "hideEmpty": false,
        "hideZero": false,
        "max": false,
        "min": false,
        "rightSide": false,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "maxPerRow": 2,
      "nullPointMode": "null",
      "options": {
        "alertThreshold": true
      },
      "percentage": false,
      "pluginVersion": "8.0.1",
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "repeatDirection": "h",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "exemplar": true,
          "expr": "sum by (cpu_id) (rate(cgroups_slurm_cpuacct_usage_per_cpu_ns{job_id=\"$job_id\",instance=~\"$node:.*\"}[$__rate_interval])/1e+9*100  * on(cpu_id,step_id,task_id,user_id) cgroups_slurm_cpuset_cpus{job_id=\"$job_id\",instance=~\"$node:.*\"})",
          "format": "time_series",
          "hide": false,
          "interval": "",
          "legendFormat": "CPU {{ cpu_id }}",
          "refId": "A"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "CPU Usage",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "$$hashKey": "object:7840",
          "format": "percent",
          "label": "Percent Usage",
          "logBase": 1,
          "max": "100",
          "min": "0",
          "show": true
        },
        {
          "$$hashKey": "object:7841",
          "format": "short",
          "label": "",
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "$prom_ds",
      "fieldConfig": {
        "defaults": {
          "links": []
        },
        "overrides": []
      },
      "fill": 1,
      "fillGradient": 0,
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 1
      },
      "hiddenSeries": false,
      "id": 12,
      "legend": {
        "avg": false,
        "current": false,
        "hideEmpty": false,
        "hideZero": false,
        "max": false,
        "min": false,
        "show": false,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "maxPerRow": 2,
      "nullPointMode": "null",
      "options": {
        "alertThreshold": true
      },
      "percentage": false,
      "pluginVersion": "8.0.1",
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "repeatDirection": "h",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "sum by (job_id) (cgroups_slurm_memory_usage_in_bytes{job_id=\"$job_id\",instance=~\"$node:.*\"}/1e+9)",
          "interval": "",
          "legendFormat": "Job {{ job_id }}",
          "refId": "A"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Memory Usage",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "$$hashKey": "object:25682",
          "format": "short",
          "label": "Memory Used (GB)",
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "$$hashKey": "object:25683",
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "$prom_ds",
      "description": "",
      "fieldConfig": {
        "defaults": {
          "links": []
        },
        "overrides": []
      },
      "fill": 1,
      "fillGradient": 0,
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 9
      },
      "hiddenSeries": false,
      "id": 17,
      "interval": "",
      "legend": {
        "alignAsTable": false,
        "avg": false,
        "current": false,
        "hideEmpty": false,
        "hideZero": false,
        "max": false,
        "min": false,
        "rightSide": false,
        "show": false,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "maxPerRow": 2,
      "nullPointMode": "null",
      "options": {
        "alertThreshold": true
      },
      "percentage": false,
      "pluginVersion": "8.0.1",
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "repeatDirection": "h",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "exemplar": true,
          "expr": "sum(rate(cgroups_slurm_cpuacct_usage_per_cpu_ns{job_id=\"$job_id\",instance=~\"$node:.*\"}[$__rate_interval]) * on(cpu_id,step_id,task_id,user_id) cgroups_slurm_cpuset_cpus{job_id=\"$job_id\",instance=~\"$node:.*\"})/(count(count by(cpu_id) (cgroups_slurm_cpuset_cpus{job_id=\"$job_id\",instance=~\"$node:.*\"}))*1e9)*100",
          "format": "time_series",
          "hide": false,
          "interval": "",
          "legendFormat": "Total CPU Usage",
          "refId": "A"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Total CPU Usage",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "$$hashKey": "object:7840",
          "format": "percent",
          "label": "Percent Usage",
          "logBase": 1,
          "max": "100",
          "min": "0",
          "show": true
        },
        {
          "$$hashKey": "object:7841",
          "format": "short",
          "label": "",
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "cacheTimeout": null,
      "datasource": "$prom_ds",
      "fieldConfig": {
        "defaults": {
          "color": {
            "fixedColor": "green",
            "mode": "fixed"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "#299c46",
                "value": null
              }
            ]
          },
          "unit": "none"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 9
      },
      "id": 16,
      "interval": null,
      "links": [],
      "maxDataPoints": 100,
      "options": {
        "colorMode": "value",
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "horizontal",
        "reduceOptions": {
          "calcs": [
            "max"
          ],
          "fields": "",
          "values": false
        },
        "text": {},
        "textMode": "auto"
      },
      "pluginVersion": "8.0.1",
      "targets": [
        {
          "expr": "count(max by (cpu_id) (cgroups_slurm_cpuset_cpus{job_id=\"$job_id\",instance=~\"$node:.*\"}))",
          "hide": false,
          "interval": "",
          "legendFormat": "Number of Allocated CPUs",
          "refId": "A"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Number of Allocated CPUs",
      "type": "stat"
    }
  ],
  "refresh": false,
  "schemaVersion": 30,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": [
      {
        "current": {
          "selected": false,
          "text": "Thanos",
          "value": "Thanos"
        },
        "description": null,
        "error": null,
        "hide": 0,
        "includeAll": false,
        "label": "Datasource",
        "multi": false,
        "name": "prom_ds",
        "options": [],
        "query": "prometheus",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "type": "datasource"
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "$prom_ds",
        "definition": "label_values(cgroups_slurm_cpuacct_usage_per_cpu_ns, job_id)",
        "description": null,
        "error": null,
        "hide": 0,
        "includeAll": false,
        "label": "Job ID",
        "multi": false,
        "name": "job_id",
        "options": [],
        "query": {
          "query": "label_values(cgroups_slurm_cpuacct_usage_per_cpu_ns, job_id)",
          "refId": "Thanos-job_id-Variable-Query"
        },
        "refresh": 2,
        "regex": "",
        "skipUrlSync": false,
        "sort": 4,
        "tagValuesQuery": "",
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "$prom_ds",
        "definition": "label_values(cgroups_slurm_cpuacct_usage_per_cpu_ns{job_id=\"$job_id\"}, instance)",
        "description": null,
        "error": null,
        "hide": 2,
        "includeAll": true,
        "label": "Node",
        "multi": true,
        "name": "node",
        "options": [],
        "query": {
          "query": "label_values(cgroups_slurm_cpuacct_usage_per_cpu_ns{job_id=\"$job_id\"}, instance)",
          "refId": "Thanos-node-Variable-Query"
        },
        "refresh": 2,
        "regex": "/^([^:]+)/",
        "skipUrlSync": false,
        "sort": 1,
        "tagValuesQuery": "",
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      }
    ]
  },
  "time": {
    "from": "now-6h",
    "to": "now"
  },
  "timepicker": {
    "refresh_intervals": [
      "5s",
      "10s",
      "30s",
      "1m",
      "5m",
      "15m",
      "30m",
      "1h",
      "2h",
      "1d"
    ]
  },
  "timezone": "",
  "title": "Slurm Cgroups",
  "uid": "iuCOu9qMz",
  "version": 22
}