{
  "__inputs": [],
  "title": "NAS Pools & Health",
  "uid": "nas-pools",
  "tags": [
    "nas",
    "zfs",
    "truenas"
  ],
  "timezone": "browser",
  "schemaVersion": 39,
  "version": 1,
  "refresh": "1m",
  "time": {
    "from": "now-7d",
    "to": "now"
  },
  "templating": {
    "list": [
      {
        "name": "host",
        "label": "NAS",
        "type": "query",
        "datasource": {
          "type": "prometheus",
          "uid": "prometheus"
        },
        "query": {
          "query": "label_values(zpool_capacity_percent, host)",
          "refId": "host"
        },
        "definition": "label_values(zpool_capacity_percent, host)",
        "multi": true,
        "includeAll": true,
        "current": {
          "selected": true,
          "text": [
            "All"
          ],
          "value": [
            "$__all"
          ]
        },
        "refresh": 2,
        "sort": 1
      }
    ]
  },
  "panels": [
    {
      "type": "row",
      "title": "ZFS pools",
      "id": 1,
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "panels": []
    },
    {
      "type": "bargauge",
      "title": "Pool usage (% full)",
      "id": 2,
      "datasource": {
        "type": "prometheus",
        "uid": "prometheus"
      },
      "description": "Percentage of each pool in use. ZFS performance drops above ~80%.",
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 1
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          },
          "expr": "zpool_capacity_percent{host=~\"$host\", pool!=\"boot-pool\"}",
          "legendFormat": "{{host}} \u00b7 {{pool}}",
          "refId": "A",
          "range": false,
          "instant": true
        }
      ],
      "options": {
        "orientation": "horizontal",
        "displayMode": "gradient",
        "showUnfilled": true,
        "valueMode": "color",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "fieldConfig": {
        "defaults": {
          "unit": "percent",
          "min": 0,
          "max": 100,
          "decimals": 0,
          "color": {
            "mode": "thresholds"
          },
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "orange",
                "value": 70
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": []
      }
    },
    {
      "type": "stat",
      "title": "Pool health",
      "id": 3,
      "datasource": {
        "type": "prometheus",
        "uid": "prometheus"
      },
      "gridPos": {
        "h": 8,
        "w": 6,
        "x": 12,
        "y": 1
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          },
          "expr": "zpool_healthy{host=~\"$host\"}",
          "legendFormat": "{{host}} \u00b7 {{pool}}",
          "refId": "A",
          "range": false,
          "instant": true
        }
      ],
      "options": {
        "colorMode": "background",
        "graphMode": "none",
        "textMode": "value_and_name",
        "justifyMode": "auto",
        "orientation": "horizontal",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "red",
                "value": null
              },
              {
                "color": "green",
                "value": 1
              }
            ]
          },
          "mappings": [
            {
              "type": "value",
              "options": {
                "1": {
                  "text": "ONLINE",
                  "color": "green"
                },
                "0": {
                  "text": "PROBLEM",
                  "color": "red"
                }
              }
            }
          ]
        },
        "overrides": []
      }
    },
    {
      "type": "stat",
      "title": "Free space (usable estimate in raw bytes)",
      "id": 4,
      "datasource": {
        "type": "prometheus",
        "uid": "prometheus"
      },
      "description": "Raw free space as reported by zpool list (includes RAIDZ parity overhead).",
      "gridPos": {
        "h": 8,
        "w": 6,
        "x": 18,
        "y": 1
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          },
          "expr": "zpool_free_bytes{host=~\"$host\", pool!=\"boot-pool\"}",
          "legendFormat": "{{host}} \u00b7 {{pool}}",
          "refId": "A",
          "range": false,
          "instant": true
        }
      ],
      "options": {
        "colorMode": "none",
        "graphMode": "none",
        "textMode": "value_and_name",
        "orientation": "horizontal",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "fieldConfig": {
        "defaults": {
          "unit": "bytes",
          "decimals": 1
        },
        "overrides": []
      }
    },
    {
      "type": "timeseries",
      "title": "Pool usage over time (%)",
      "id": 5,
      "datasource": {
        "type": "prometheus",
        "uid": "prometheus"
      },
      "gridPos": {
        "h": 9,
        "w": 12,
        "x": 0,
        "y": 9
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          },
          "expr": "zpool_capacity_percent{host=~\"$host\", pool!=\"boot-pool\"}",
          "legendFormat": "{{host}} \u00b7 {{pool}}",
          "refId": "A",
          "range": true,
          "instant": false
        }
      ],
      "options": {
        "legend": {
          "displayMode": "table",
          "placement": "bottom",
          "calcs": [
            "lastNotNull",
            "max"
          ]
        },
        "tooltip": {
          "mode": "multi"
        }
      },
      "fieldConfig": {
        "defaults": {
          "unit": "percent",
          "min": 0,
          "max": 100,
          "custom": {
            "lineWidth": 2,
            "fillOpacity": 10,
            "spanNulls": true,
            "thresholdsStyle": {
              "mode": "area"
            }
          },
          "color": {
            "mode": "palette-classic"
          },
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "transparent",
                "value": null
              },
              {
                "color": "orange",
                "value": 70
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": []
      }
    },
    {
      "type": "timeseries",
      "title": "Space used over time",
      "id": 6,
      "datasource": {
        "type": "prometheus",
        "uid": "prometheus"
      },
      "gridPos": {
        "h": 9,
        "w": 12,
        "x": 12,
        "y": 9
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          },
          "expr": "zpool_allocated_bytes{host=~\"$host\", pool!=\"boot-pool\"}",
          "legendFormat": "{{host}} \u00b7 {{pool}}",
          "refId": "A",
          "range": true,
          "instant": false
        }
      ],
      "options": {
        "legend": {
          "displayMode": "table",
          "placement": "bottom",
          "calcs": [
            "lastNotNull",
            "min",
            "max"
          ]
        },
        "tooltip": {
          "mode": "multi"
        }
      },
      "fieldConfig": {
        "defaults": {
          "unit": "bytes",
          "custom": {
            "lineWidth": 2,
            "fillOpacity": 10,
            "spanNulls": true
          },
          "color": {
            "mode": "palette-classic"
          }
        },
        "overrides": []
      }
    },
    {
      "type": "stat",
      "title": "Growth per day (7-day trend)",
      "id": 7,
      "datasource": {
        "type": "prometheus",
        "uid": "prometheus"
      },
      "description": "Average change in used space per day over the last 7 days. Needs a few days of data to be meaningful.",
      "gridPos": {
        "h": 6,
        "w": 12,
        "x": 0,
        "y": 18
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          },
          "expr": "deriv(zpool_allocated_bytes{host=~\"$host\", pool!=\"boot-pool\"}[7d]) * 86400",
          "legendFormat": "{{host}} \u00b7 {{pool}}",
          "refId": "A",
          "range": false,
          "instant": true
        }
      ],
      "options": {
        "colorMode": "value",
        "graphMode": "none",
        "textMode": "value_and_name",
        "orientation": "horizontal",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "fieldConfig": {
        "defaults": {
          "unit": "bytes",
          "decimals": 1,
          "color": {
            "mode": "fixed",
            "fixedColor": "blue"
          }
        },
        "overrides": []
      }
    },
    {
      "type": "stat",
      "title": "Days until 80% full (forecast)",
      "id": 8,
      "datasource": {
        "type": "prometheus",
        "uid": "prometheus"
      },
      "description": "Linear forecast from the last 7 days of growth. Empty if the pool is not growing.",
      "gridPos": {
        "h": 6,
        "w": 12,
        "x": 12,
        "y": 18
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          },
          "expr": "((zpool_size_bytes{host=~\"$host\", pool!=\"boot-pool\"} * 0.8) - zpool_allocated_bytes{host=~\"$host\", pool!=\"boot-pool\"}) / (deriv(zpool_allocated_bytes{host=~\"$host\", pool!=\"boot-pool\"}[7d]) * 86400 > 0)",
          "legendFormat": "{{host}} \u00b7 {{pool}}",
          "refId": "A",
          "range": false,
          "instant": true
        }
      ],
      "options": {
        "colorMode": "background",
        "graphMode": "none",
        "textMode": "value_and_name",
        "orientation": "horizontal",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "fieldConfig": {
        "defaults": {
          "unit": "d",
          "decimals": 0,
          "color": {
            "mode": "thresholds"
          },
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "red",
                "value": null
              },
              {
                "color": "orange",
                "value": 30
              },
              {
                "color": "green",
                "value": 180
              }
            ]
          },
          "noValue": "not growing"
        },
        "overrides": []
      }
    },
    {
      "type": "row",
      "title": "NAS hardware",
      "id": 9,
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 24
      },
      "panels": []
    },
    {
      "type": "timeseries",
      "title": "CPU usage",
      "id": 10,
      "datasource": {
        "type": "prometheus",
        "uid": "prometheus"
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 25
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          },
          "expr": "100 - avg by (host) (rate(node_cpu_seconds_total{mode=\"idle\", host=~\"$host\"}[5m])) * 100",
          "legendFormat": "{{host}}",
          "refId": "A",
          "range": true,
          "instant": false
        }
      ],
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi"
        }
      },
      "fieldConfig": {
        "defaults": {
          "unit": "percent",
          "min": 0,
          "max": 100,
          "custom": {
            "lineWidth": 2,
            "fillOpacity": 10
          }
        },
        "overrides": []
      }
    },
    {
      "type": "timeseries",
      "title": "Memory: used (excl. ARC) and ZFS ARC cache",
      "id": 11,
      "datasource": {
        "type": "prometheus",
        "uid": "prometheus"
      },
      "description": "ZFS uses free RAM as read cache (ARC). High total RAM use on TrueNAS is normal.",
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 25
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          },
          "expr": "node_memory_MemTotal_bytes{host=~\"$host\"} - node_memory_MemAvailable_bytes{host=~\"$host\"} - node_zfs_arc_size{host=~\"$host\"}",
          "legendFormat": "{{host}} \u00b7 apps & system",
          "refId": "A",
          "range": true,
          "instant": false
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          },
          "expr": "node_zfs_arc_size{host=~\"$host\"}",
          "legendFormat": "{{host}} \u00b7 ZFS ARC",
          "refId": "B",
          "range": true,
          "instant": false
        }
      ],
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi"
        }
      },
      "fieldConfig": {
        "defaults": {
          "unit": "bytes",
          "min": 0,
          "custom": {
            "lineWidth": 2,
            "fillOpacity": 10
          }
        },
        "overrides": []
      }
    },
    {
      "type": "timeseries",
      "title": "Temperatures",
      "id": 12,
      "datasource": {
        "type": "prometheus",
        "uid": "prometheus"
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 33
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          },
          "expr": "node_hwmon_temp_celsius{host=~\"$host\"}",
          "legendFormat": "{{host}} \u00b7 {{chip}} {{sensor}}",
          "refId": "A",
          "range": true,
          "instant": false
        }
      ],
      "options": {
        "legend": {
          "displayMode": "table",
          "placement": "right",
          "calcs": [
            "lastNotNull",
            "max"
          ]
        },
        "tooltip": {
          "mode": "multi"
        }
      },
      "fieldConfig": {
        "defaults": {
          "unit": "celsius",
          "custom": {
            "lineWidth": 1,
            "fillOpacity": 0
          }
        },
        "overrides": []
      }
    },
    {
      "type": "timeseries",
      "title": "Network traffic",
      "id": 13,
      "datasource": {
        "type": "prometheus",
        "uid": "prometheus"
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 33
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          },
          "expr": "rate(node_network_receive_bytes_total{host=~\"$host\", device!~\"lo|veth.*|docker.*|br-.*|kube.*|vb-.*|tailscale.*\"}[5m]) * 8",
          "legendFormat": "{{host}} {{device}} in",
          "refId": "A",
          "range": true,
          "instant": false
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          },
          "expr": "-rate(node_network_transmit_bytes_total{host=~\"$host\", device!~\"lo|veth.*|docker.*|br-.*|kube.*|vb-.*|tailscale.*\"}[5m]) * 8",
          "legendFormat": "{{host}} {{device}} out",
          "refId": "B",
          "range": true,
          "instant": false
        }
      ],
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi"
        }
      },
      "fieldConfig": {
        "defaults": {
          "unit": "bps",
          "custom": {
            "lineWidth": 1,
            "fillOpacity": 10
          }
        },
        "overrides": []
      }
    },
    {
      "type": "timeseries",
      "title": "Disk throughput (read up / write down)",
      "id": 14,
      "datasource": {
        "type": "prometheus",
        "uid": "prometheus"
      },
      "gridPos": {
        "h": 8,
        "w": 24,
        "x": 0,
        "y": 41
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          },
          "expr": "rate(node_disk_read_bytes_total{host=~\"$host\", device=~\"sd[a-z]+|nvme[0-9]+n[0-9]+\"}[5m])",
          "legendFormat": "{{host}} {{device}} read",
          "refId": "A",
          "range": true,
          "instant": false
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          },
          "expr": "-rate(node_disk_written_bytes_total{host=~\"$host\", device=~\"sd[a-z]+|nvme[0-9]+n[0-9]+\"}[5m])",
          "legendFormat": "{{host}} {{device}} write",
          "refId": "B",
          "range": true,
          "instant": false
        }
      ],
      "options": {
        "legend": {
          "displayMode": "table",
          "placement": "right",
          "calcs": [
            "max"
          ]
        },
        "tooltip": {
          "mode": "multi"
        }
      },
      "fieldConfig": {
        "defaults": {
          "unit": "Bps",
          "custom": {
            "lineWidth": 1,
            "fillOpacity": 10
          }
        },
        "overrides": []
      }
    }
  ],
  "annotations": {
    "list": []
  },
  "editable": true
}