# services/monitoring/grafana-dashboard-storage.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: grafana-dashboard-storage
  labels:
    grafana_dashboard: "1"
data:
  atlas-storage.json: |
    {
      "uid": "atlas-storage",
      "title": "Atlas Storage",
      "folderUid": "atlas-internal",
      "editable": true,
      "panels": [
        {
          "id": 1,
          "type": "stat",
          "title": "Astreae Usage",
          "datasource": {
            "type": "prometheus",
            "uid": "atlas-vm"
          },
          "gridPos": {
            "h": 5,
            "w": 6,
            "x": 0,
            "y": 0
          },
          "targets": [
            {
              "expr": "100 - (sum(node_filesystem_avail_bytes{mountpoint=\"/mnt/astreae\",fstype!~\"tmpfs|overlay\"}) / sum(node_filesystem_size_bytes{mountpoint=\"/mnt/astreae\",fstype!~\"tmpfs|overlay\"}) * 100)",
              "refId": "A"
            }
          ],
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "thresholds"
              },
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "dark-green",
                    "value": null
                  },
                  {
                    "color": "dark-yellow",
                    "value": 50
                  },
                  {
                    "color": "dark-orange",
                    "value": 75
                  },
                  {
                    "color": "dark-red",
                    "value": 91.5
                  }
                ]
              },
              "unit": "percent",
              "custom": {
                "displayMode": "auto"
              }
            },
            "overrides": []
          },
          "options": {
            "colorMode": "value",
            "graphMode": "area",
            "justifyMode": "center",
            "reduceOptions": {
              "calcs": [
                "lastNotNull"
              ],
              "fields": "",
              "values": false
            },
            "textMode": "value"
          }
        },
        {
          "id": 2,
          "type": "stat",
          "title": "Asteria Usage",
          "datasource": {
            "type": "prometheus",
            "uid": "atlas-vm"
          },
          "gridPos": {
            "h": 5,
            "w": 6,
            "x": 6,
            "y": 0
          },
          "targets": [
            {
              "expr": "100 - (sum(node_filesystem_avail_bytes{mountpoint=\"/mnt/asteria\",fstype!~\"tmpfs|overlay\"}) / sum(node_filesystem_size_bytes{mountpoint=\"/mnt/asteria\",fstype!~\"tmpfs|overlay\"}) * 100)",
              "refId": "A"
            }
          ],
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "thresholds"
              },
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "dark-green",
                    "value": null
                  },
                  {
                    "color": "dark-yellow",
                    "value": 50
                  },
                  {
                    "color": "dark-orange",
                    "value": 75
                  },
                  {
                    "color": "dark-red",
                    "value": 91.5
                  }
                ]
              },
              "unit": "percent",
              "custom": {
                "displayMode": "auto"
              }
            },
            "overrides": []
          },
          "options": {
            "colorMode": "value",
            "graphMode": "area",
            "justifyMode": "center",
            "reduceOptions": {
              "calcs": [
                "lastNotNull"
              ],
              "fields": "",
              "values": false
            },
            "textMode": "value"
          }
        },
        {
          "id": 3,
          "type": "stat",
          "title": "Astreae Free",
          "datasource": {
            "type": "prometheus",
            "uid": "atlas-vm"
          },
          "gridPos": {
            "h": 5,
            "w": 6,
            "x": 12,
            "y": 0
          },
          "targets": [
            {
              "expr": "sum(node_filesystem_avail_bytes{mountpoint=\"/mnt/astreae\",fstype!~\"tmpfs|overlay\"})",
              "refId": "A"
            }
          ],
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "thresholds"
              },
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "rgba(115, 115, 115, 1)",
                    "value": null
                  },
                  {
                    "color": "dark-green",
                    "value": 1
                  }
                ]
              },
              "unit": "decbytes",
              "custom": {
                "displayMode": "auto"
              }
            },
            "overrides": []
          },
          "options": {
            "colorMode": "value",
            "graphMode": "area",
            "justifyMode": "center",
            "reduceOptions": {
              "calcs": [
                "lastNotNull"
              ],
              "fields": "",
              "values": false
            },
            "textMode": "value"
          }
        },
        {
          "id": 4,
          "type": "stat",
          "title": "Asteria Free",
          "datasource": {
            "type": "prometheus",
            "uid": "atlas-vm"
          },
          "gridPos": {
            "h": 5,
            "w": 6,
            "x": 18,
            "y": 0
          },
          "targets": [
            {
              "expr": "sum(node_filesystem_avail_bytes{mountpoint=\"/mnt/asteria\",fstype!~\"tmpfs|overlay\"})",
              "refId": "A"
            }
          ],
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "thresholds"
              },
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "rgba(115, 115, 115, 1)",
                    "value": null
                  },
                  {
                    "color": "dark-green",
                    "value": 1
                  }
                ]
              },
              "unit": "decbytes",
              "custom": {
                "displayMode": "auto"
              }
            },
            "overrides": []
          },
          "options": {
            "colorMode": "value",
            "graphMode": "area",
            "justifyMode": "center",
            "reduceOptions": {
              "calcs": [
                "lastNotNull"
              ],
              "fields": "",
              "values": false
            },
            "textMode": "value"
          }
        },
        {
          "id": 5,
          "type": "timeseries",
          "title": "Astreae Per-Node Usage",
          "datasource": {
            "type": "prometheus",
            "uid": "atlas-vm"
          },
          "gridPos": {
            "h": 9,
            "w": 12,
            "x": 0,
            "y": 5
          },
          "targets": [
            {
              "expr": "(avg by (node) ((avg by (instance) ((1 - (node_filesystem_avail_bytes{mountpoint=\"/mnt/astreae\",fstype!~\"tmpfs|overlay\"} / node_filesystem_size_bytes{mountpoint=\"/mnt/astreae\",fstype!~\"tmpfs|overlay\"})) * 100)) * on(instance) group_left(node) label_replace(node_uname_info{nodename!=\"\"}, \"node\", \"$1\", \"nodename\", \"(.*)\"))) * on(node) group_left() label_replace(node_uname_info{nodename=~\"titan-1[2-9]|titan-2[24]\"}, \"node\", \"$1\", \"nodename\", \"(.*)\")",
              "refId": "A",
              "legendFormat": "{{node}}"
            }
          ],
          "fieldConfig": {
            "defaults": {
              "unit": "percent"
            },
            "overrides": []
          },
          "options": {
            "legend": {
              "displayMode": "table",
              "placement": "right"
            },
            "tooltip": {
              "mode": "multi"
            }
          },
          "timeFrom": "30d"
        },
        {
          "id": 6,
          "type": "timeseries",
          "title": "Asteria Per-Node Usage",
          "datasource": {
            "type": "prometheus",
            "uid": "atlas-vm"
          },
          "gridPos": {
            "h": 9,
            "w": 12,
            "x": 12,
            "y": 5
          },
          "targets": [
            {
              "expr": "(avg by (node) ((avg by (instance) ((1 - (node_filesystem_avail_bytes{mountpoint=\"/mnt/asteria\",fstype!~\"tmpfs|overlay\"} / node_filesystem_size_bytes{mountpoint=\"/mnt/asteria\",fstype!~\"tmpfs|overlay\"})) * 100)) * on(instance) group_left(node) label_replace(node_uname_info{nodename!=\"\"}, \"node\", \"$1\", \"nodename\", \"(.*)\"))) * on(node) group_left() label_replace(node_uname_info{nodename=~\"titan-1[2-9]|titan-2[24]\"}, \"node\", \"$1\", \"nodename\", \"(.*)\")",
              "refId": "A",
              "legendFormat": "{{node}}"
            }
          ],
          "fieldConfig": {
            "defaults": {
              "unit": "percent"
            },
            "overrides": []
          },
          "options": {
            "legend": {
              "displayMode": "table",
              "placement": "right"
            },
            "tooltip": {
              "mode": "multi"
            }
          },
          "timeFrom": "30d"
        },
        {
          "id": 7,
          "type": "timeseries",
          "title": "Astreae Usage History",
          "datasource": {
            "type": "prometheus",
            "uid": "atlas-vm"
          },
          "gridPos": {
            "h": 9,
            "w": 12,
            "x": 0,
            "y": 14
          },
          "targets": [
            {
              "expr": "100 - (sum(node_filesystem_avail_bytes{mountpoint=\"/mnt/astreae\",fstype!~\"tmpfs|overlay\"}) / sum(node_filesystem_size_bytes{mountpoint=\"/mnt/astreae\",fstype!~\"tmpfs|overlay\"}) * 100)",
              "refId": "A"
            }
          ],
          "fieldConfig": {
            "defaults": {
              "unit": "percent"
            },
            "overrides": []
          },
          "options": {
            "legend": {
              "displayMode": "table",
              "placement": "bottom"
            },
            "tooltip": {
              "mode": "multi"
            }
          },
          "timeFrom": "90d"
        },
        {
          "id": 8,
          "type": "timeseries",
          "title": "Asteria Usage History",
          "datasource": {
            "type": "prometheus",
            "uid": "atlas-vm"
          },
          "gridPos": {
            "h": 9,
            "w": 12,
            "x": 12,
            "y": 14
          },
          "targets": [
            {
              "expr": "100 - (sum(node_filesystem_avail_bytes{mountpoint=\"/mnt/asteria\",fstype!~\"tmpfs|overlay\"}) / sum(node_filesystem_size_bytes{mountpoint=\"/mnt/asteria\",fstype!~\"tmpfs|overlay\"}) * 100)",
              "refId": "A"
            }
          ],
          "fieldConfig": {
            "defaults": {
              "unit": "percent"
            },
            "overrides": []
          },
          "options": {
            "legend": {
              "displayMode": "table",
              "placement": "bottom"
            },
            "tooltip": {
              "mode": "multi"
            }
          },
          "timeFrom": "90d"
        },
        {
          "id": 30,
          "type": "stat",
          "title": "Maintenance Sweepers Ready",
          "datasource": {
            "type": "prometheus",
            "uid": "atlas-vm"
          },
          "gridPos": {
            "h": 4,
            "w": 12,
            "x": 0,
            "y": 44
          },
          "targets": [
            {
              "expr": "kube_daemonset_status_number_ready{namespace=\"maintenance\",daemonset=\"node-image-sweeper\"} / on(namespace,daemonset) kube_daemonset_status_desired_number_scheduled{namespace=\"maintenance\",daemonset=\"node-image-sweeper\"} * 100",
              "refId": "A"
            }
          ],
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "thresholds"
              },
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "dark-green",
                    "value": null
                  },
                  {
                    "color": "dark-yellow",
                    "value": 50
                  },
                  {
                    "color": "dark-orange",
                    "value": 75
                  },
                  {
                    "color": "dark-red",
                    "value": 91.5
                  }
                ]
              },
              "unit": "percent",
              "custom": {
                "displayMode": "auto"
              }
            },
            "overrides": []
          },
          "options": {
            "colorMode": "value",
            "graphMode": "area",
            "justifyMode": "center",
            "reduceOptions": {
              "calcs": [
                "lastNotNull"
              ],
              "fields": "",
              "values": false
            },
            "textMode": "value"
          }
        },
        {
          "id": 31,
          "type": "stat",
          "title": "Maintenance Cron Freshness (s)",
          "datasource": {
            "type": "prometheus",
            "uid": "atlas-vm"
          },
          "gridPos": {
            "h": 4,
            "w": 12,
            "x": 12,
            "y": 44
          },
          "targets": [
            {
              "expr": "time() - max by (cronjob) (kube_cronjob_status_last_successful_time{namespace=\"maintenance\",cronjob=\"image-sweeper\"})",
              "refId": "A"
            }
          ],
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "thresholds"
              },
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "dark-green",
                    "value": null
                  },
                  {
                    "color": "dark-yellow",
                    "value": 3600
                  },
                  {
                    "color": "dark-red",
                    "value": 10800
                  }
                ]
              },
              "unit": "s",
              "custom": {
                "displayMode": "auto"
              }
            },
            "overrides": []
          },
          "options": {
            "colorMode": "value",
            "graphMode": "area",
            "justifyMode": "center",
            "reduceOptions": {
              "calcs": [
                "lastNotNull"
              ],
              "fields": "",
              "values": false
            },
            "textMode": "value"
          }
        }
      ],
      "time": {
        "from": "now-12h",
        "to": "now"
      },
      "annotations": {
        "list": []
      },
      "schemaVersion": 39,
      "style": "dark",
      "tags": [
        "atlas",
        "storage"
      ]
    }
