Grafana dashboard: SMART disk data
Description: Extended smartmon Dashboard for disk SMART data

Dashboard for displaying SMART information of disks readable via smartmontools/smartctl.

I created a fork of the [node-exporter textfile collector script](https://github.com/prometheus-community/node-exporter-textfile-collector-scripts) `smartmon.sh`, and extended its functionality ab bit, most notably

* Adding extensive device info labels on all metrics
* Adding metrics for the information encoded in the return value of smartctl:
    ```
    smartmon_smartctl_statusbit_commandline_not_parsed
    smartmon_smartctl_statusbit_device_open_failed
    smartmon_smartctl_statusbit_device_command_failed
    smartmon_smartctl_statusbit_disk_failing
    smartmon_smartctl_statusbit_prefail_attributes_below_thresh
    smartmon_smartctl_statusbit_disk_ok_previous_prefail_attributes
    smartmon_smartctl_statusbit_device_error_log_has_errors
    smartmon_smartctl_statusbit_device_selftest_log_has_errors
    ```

You can find my [fork of the script here](https://github.com/janw/node-exporter-textfile-collector-scripts/blob/master/smartmon.sh). 

{
  "__inputs": [
    {
      "name": "DS_PROMETHEUS",
      "label": "Prometheus",
      "description": "",
      "type": "datasource",
      "pluginId": "prometheus",
      "pluginName": "Prometheus"
    }
  ],
  "__requires": [
    {
      "type": "panel",
      "id": "gauge",
      "name": "Gauge",
      "version": ""
    },
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "6.4.4"
    },
    {
      "type": "panel",
      "id": "graph",
      "name": "Graph",
      "version": ""
    },
    {
      "type": "datasource",
      "id": "prometheus",
      "name": "Prometheus",
      "version": "1.0.0"
    },
    {
      "type": "panel",
      "id": "table",
      "name": "Table",
      "version": ""
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "description": "Extended smartmon Dashboard for disk SMART data",
  "editable": true,
  "gnetId": 10664,
  "graphTooltip": 0,
  "id": null,
  "iteration": 1574521336451,
  "links": [],
  "panels": [
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_PROMETHEUS}",
      "fill": 0,
      "fillGradient": 0,
      "gridPos": {
        "h": 7,
        "w": 13,
        "x": 0,
        "y": 0
      },
      "id": 1,
      "interval": "",
      "legend": {
        "alignAsTable": true,
        "avg": true,
        "current": true,
        "max": true,
        "min": false,
        "rightSide": true,
        "show": true,
        "sideWidth": null,
        "sort": "current",
        "sortDesc": true,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "connected",
      "options": {
        "dataLinks": []
      },
      "percentage": false,
      "pointradius": 1,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "avg(smartmon_temperature_celsius_raw_value{instance=~\"$instance\",disk=~\"$disk\",type=~\"$type\",serial_number=~\"$serial_number\",model_family=~\"$model_family\",device_model=~\"$device_model\"}) by (device_model,serial_number)",
          "format": "time_series",
          "hide": false,
          "instant": false,
          "interval": "1m",
          "intervalFactor": 1,
          "legendFormat": "{{device_model}} (S/N: {{serial_number}})",
          "refId": "B"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Disk Temperature",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "decimals": null,
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": "60",
          "min": "20",
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": false
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "columns": [],
      "datasource": "${DS_PROMETHEUS}",
      "fontSize": "100%",
      "gridPos": {
        "h": 5,
        "w": 11,
        "x": 13,
        "y": 0
      },
      "id": 12,
      "links": [],
      "options": {},
      "pageSize": null,
      "scroll": true,
      "showHeader": true,
      "sort": {
        "col": 0,
        "desc": true
      },
      "styles": [
        {
          "alias": "Time",
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "pattern": "Time",
          "type": "hidden"
        },
        {
          "alias": "Healthy",
          "colorMode": "row",
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "#73BF69",
            "#73BF69"
          ],
          "decimals": 2,
          "mappingType": 1,
          "pattern": "Value",
          "thresholds": [
            "1"
          ],
          "type": "string",
          "unit": "short",
          "valueMaps": [
            {
              "text": "Yes",
              "value": "1"
            },
            {
              "text": "No",
              "value": "0"
            }
          ]
        }
      ],
      "targets": [
        {
          "expr": "  max(smartmon_device_smart_healthy{instance=~\"$instance\",disk=~\"$disk\",type=~\"$type\",serial_number=~\"$serial_number\",model_family=~\"$model_family\",device_model=~\"$device_model\"}) by (disk,device_model,serial_number) < 1",
          "format": "table",
          "instant": true,
          "intervalFactor": 1,
          "refId": "A"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Unhealthy Disks",
      "transform": "table",
      "type": "table"
    },
    {
      "aliasColors": {},
      "bars": true,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_PROMETHEUS}",
      "decimals": 0,
      "fill": 1,
      "fillGradient": 0,
      "gridPos": {
        "h": 5,
        "w": 11,
        "x": 13,
        "y": 5
      },
      "id": 5,
      "legend": {
        "alignAsTable": false,
        "avg": false,
        "current": true,
        "hideEmpty": false,
        "hideZero": true,
        "max": false,
        "min": false,
        "rightSide": false,
        "show": true,
        "total": false,
        "values": true
      },
      "lines": false,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "options": {
        "dataLinks": []
      },
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": true,
      "targets": [
        {
          "expr": "smartmon_reallocated_sector_ct_raw_value{instance=~\"$instance\",disk=~\"$disk\",type=~\"$type\",serial_number=~\"$serial_number\",model_family=~\"$model_family\",device_model=~\"$device_model\"} > 0",
          "format": "time_series",
          "interval": "",
          "intervalFactor": 2,
          "legendFormat": "Reallocated {{disk}}",
          "refId": "B"
        },
        {
          "expr": "smartmon_current_pending_sector_raw_value{instance=~\"$instance\",disk=~\"$disk\",type=~\"$type\",serial_number=~\"$serial_number\",model_family=~\"$model_family\",device_model=~\"$device_model\"} > 0",
          "format": "time_series",
          "interval": "",
          "intervalFactor": 2,
          "legendFormat": "Pending {{disk}}",
          "refId": "A"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Pending and Reallocated Sectors",
      "tooltip": {
        "shared": true,
        "sort": 2,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "decimals": 0,
          "format": "short",
          "label": "",
          "logBase": 1,
          "max": null,
          "min": "0",
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": false
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "columns": [],
      "datasource": "${DS_PROMETHEUS}",
      "fontSize": "100%",
      "gridPos": {
        "h": 10,
        "w": 13,
        "x": 0,
        "y": 7
      },
      "id": 10,
      "interval": "1h",
      "links": [],
      "options": {},
      "pageSize": null,
      "scroll": true,
      "showHeader": true,
      "sort": {
        "col": 4,
        "desc": true
      },
      "styles": [
        {
          "alias": "",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "Time",
          "thresholds": [],
          "type": "hidden",
          "unit": "short"
        },
        {
          "alias": "Power On Time",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "decimals": 2,
          "pattern": "Value #A",
          "thresholds": [],
          "type": "number",
          "unit": "h"
        },
        {
          "alias": "",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "instance",
          "thresholds": [],
          "type": "hidden",
          "unit": "short"
        },
        {
          "alias": "Load Cycles",
          "colorMode": "value",
          "colors": [
            "rgba(50, 172, 45, 0.97)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(245, 54, 54, 0.9)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 1,
          "mappingType": 1,
          "pattern": "Value #B",
          "thresholds": [
            "20000",
            "50000"
          ],
          "type": "number",
          "unit": "short",
          "valueMaps": [
            {
              "text": "",
              "value": ""
            },
            {
              "text": "",
              "value": ""
            }
          ]
        },
        {
          "alias": "Healthy",
          "colorMode": "row",
          "colors": [
            "#F2495C",
            "#F2495C",
            "rgb(14, 54, 10)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "Value #C",
          "thresholds": [
            "0",
            "1"
          ],
          "type": "string",
          "unit": "short",
          "valueMaps": [
            {
              "text": "Yes",
              "value": "1"
            },
            {
              "text": "No",
              "value": "0"
            }
          ]
        }
      ],
      "targets": [
        {
          "expr": "max(smartmon_power_on_hours_raw_value{instance=~\"$instance\",disk=~\"$disk\",type=~\"$type\",serial_number=~\"$serial_number\",model_family=~\"$model_family\",device_model=~\"$device_model\"}) by (device_model,serial_number)",
          "format": "table",
          "instant": true,
          "interval": "",
          "intervalFactor": 2,
          "legendFormat": "",
          "refId": "A"
        },
        {
          "expr": "max(smartmon_load_cycle_count_raw_value{instance=~\"$instance\",disk=~\"$disk\",type=~\"$type\",serial_number=~\"$serial_number\",model_family=~\"$model_family\",device_model=~\"$device_model\"}) by (device_model,serial_number)",
          "format": "table",
          "instant": true,
          "interval": "",
          "intervalFactor": 2,
          "legendFormat": "Load Cycles",
          "refId": "B"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Disk Lifetime",
      "transform": "table",
      "type": "table"
    },
    {
      "datasource": "${DS_PROMETHEUS}",
      "gridPos": {
        "h": 6,
        "w": 11,
        "x": 13,
        "y": 10
      },
      "id": 8,
      "links": [],
      "options": {
        "fieldOptions": {
          "calcs": [
            "last"
          ],
          "defaults": {
            "mappings": [],
            "max": 100,
            "min": 0,
            "thresholds": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "#EAB839",
                "value": 60
              },
              {
                "color": "red",
                "value": 80
              }
            ],
            "title": "",
            "unit": "percent"
          },
          "override": {},
          "values": false
        },
        "orientation": "horizontal",
        "showThresholdLabels": false,
        "showThresholdMarkers": true
      },
      "pluginVersion": "6.4.4",
      "targets": [
        {
          "expr": "sort_desc(100 - smartmon_wear_leveling_count_value {instance=~\"$instance\",disk=~\"$disk\",type=~\"$type\",serial_number=~\"$serial_number\",model_family=~\"$model_family\",device_model=~\"$device_model\"})",
          "format": "time_series",
          "instant": true,
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": "{{disk}}",
          "refId": "A"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Wear Level on SSDs",
      "type": "gauge"
    },
    {
      "cacheTimeout": null,
      "columns": [],
      "datasource": "${DS_PROMETHEUS}",
      "fontSize": "100%",
      "gridPos": {
        "h": 6,
        "w": 11,
        "x": 13,
        "y": 16
      },
      "id": 3,
      "links": [],
      "options": {},
      "pageSize": null,
      "pluginVersion": "6.2.5",
      "scroll": true,
      "showHeader": true,
      "sort": {
        "col": 2,
        "desc": false
      },
      "styles": [
        {
          "alias": "Total Written",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "decimals": 1,
          "pattern": "Value #B",
          "thresholds": [],
          "type": "number",
          "unit": "bytes"
        },
        {
          "alias": "",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "link": false,
          "mappingType": 1,
          "pattern": "Time|instance|model_family|job|lun_id|product|revision|smart_id|type|vendor|firmware_version",
          "thresholds": [],
          "type": "hidden",
          "unit": "short"
        },
        {
          "alias": "Wear Level",
          "colorMode": "value",
          "colors": [
            "rgba(50, 172, 45, 0.97)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(245, 54, 54, 0.9)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 0,
          "mappingType": 1,
          "pattern": "Value #A",
          "thresholds": [
            "60",
            "80"
          ],
          "type": "number",
          "unit": "percent"
        }
      ],
      "targets": [
        {
          "expr": "(smartmon_total_lbas_written_raw_value{instance=~\"$instance\",disk=~\"$disk\",type=~\"$type\",serial_number=~\"$serial_number\",model_family=~\"$model_family\",device_model=~\"$device_model\"} * on(disk,instance,device_model,serial_number) smartmon_device_sector_size_logical)",
          "format": "table",
          "instant": true,
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": "{{disk}} ({{device_model}}, sn: {{serial_number}})",
          "refId": "B"
        },
        {
          "expr": "(100 - smartmon_wear_leveling_count_value {instance=~\"$instance\",disk=~\"$disk\",type=~\"$type\",serial_number=~\"$serial_number\",model_family=~\"$model_family\",device_model=~\"$device_model\"})",
          "format": "table",
          "instant": true,
          "intervalFactor": 1,
          "refId": "A"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Total Data Written on SSDs",
      "transform": "table",
      "type": "table"
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_PROMETHEUS}",
      "decimals": 0,
      "fill": 1,
      "fillGradient": 0,
      "gridPos": {
        "h": 5,
        "w": 13,
        "x": 0,
        "y": 17
      },
      "id": 2,
      "legend": {
        "alignAsTable": true,
        "avg": false,
        "current": true,
        "hideEmpty": false,
        "hideZero": true,
        "max": false,
        "min": false,
        "rightSide": true,
        "show": true,
        "sort": "current",
        "sortDesc": true,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "options": {
        "dataLinks": []
      },
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": true,
      "targets": [
        {
          "expr": "avg(smartmon_raw_read_error_rate_raw_value{instance=~\"$instance\",disk=~\"$disk\",type=~\"$type\",serial_number=~\"$serial_number\",model_family=~\"$model_family\",device_model=~\"$device_model\"}) by (device_model,serial_number) > 0",
          "format": "time_series",
          "hide": false,
          "interval": "",
          "intervalFactor": 2,
          "legendFormat": "{{device_model}} (S/N: {{serial_number}})",
          "refId": "A"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Raw Error Read Rate",
      "tooltip": {
        "shared": true,
        "sort": 2,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "decimals": 0,
          "format": "short",
          "label": "",
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": false
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    }
  ],
  "refresh": "1m",
  "schemaVersion": 20,
  "style": "dark",
  "tags": [
    "prometheus",
    "node_exporter",
    "smartmon"
  ],
  "templating": {
    "list": [
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_PROMETHEUS}",
        "definition": "",
        "hide": 0,
        "includeAll": true,
        "label": null,
        "multi": true,
        "name": "instance",
        "options": [],
        "query": "label_values(smartmon_smartctl_version, instance)",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 1,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_PROMETHEUS}",
        "definition": "label_values(smartmon_device_smart_available, disk)",
        "hide": 0,
        "includeAll": true,
        "label": null,
        "multi": true,
        "name": "disk",
        "options": [],
        "query": "label_values(smartmon_device_smart_available, disk)",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 1,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_PROMETHEUS}",
        "definition": "label_values(smartmon_device_smart_available, type)",
        "hide": 0,
        "includeAll": true,
        "label": null,
        "multi": true,
        "name": "type",
        "options": [],
        "query": "label_values(smartmon_device_smart_available, type)",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 1,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_PROMETHEUS}",
        "definition": "label_values(smartmon_device_smart_available, device_model)",
        "hide": 0,
        "includeAll": true,
        "label": null,
        "multi": true,
        "name": "device_model",
        "options": [],
        "query": "label_values(smartmon_device_smart_available, device_model)",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 1,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_PROMETHEUS}",
        "definition": "label_values(smartmon_device_smart_available, serial_number)",
        "hide": 0,
        "includeAll": true,
        "label": null,
        "multi": true,
        "name": "serial_number",
        "options": [],
        "query": "label_values(smartmon_device_smart_available, serial_number)",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 1,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_PROMETHEUS}",
        "definition": "label_values(smartmon_device_smart_available, model_family)",
        "hide": 0,
        "includeAll": true,
        "label": null,
        "multi": true,
        "name": "model_family",
        "options": [],
        "query": "label_values(smartmon_device_smart_available, model_family)",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 1,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      }
    ]
  },
  "time": {
    "from": "now-7d",
    "to": "now"
  },
  "timepicker": {
    "refresh_intervals": [
      "1m",
      "5m",
      "15m",
      "30m",
      "1h",
      "2h",
      "1d"
    ],
    "time_options": [
      "5m",
      "15m",
      "1h",
      "6h",
      "12h",
      "24h",
      "2d",
      "7d",
      "30d"
    ]
  },
  "timezone": "browser",
  "title": "SMART disk data",
  "uid": "eak7BovZk",
  "version": 24
}