apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDashboard
metadata:
  name: irc-now-overview
  namespace: irc-josie-cloud
spec:
  instanceSelector:
    matchLabels:
      dashboards: irc-now
  folder: admin
  json: |
    {
      "uid": "irc-now-overview",
      "title": "irc.now Overview",
      "timezone": "browser",
      "refresh": "30s",
      "time": { "from": "now-24h", "to": "now" },
      "panels": [
        {
          "id": 1,
          "title": "Users",
          "type": "stat",
          "gridPos": { "h": 4, "w": 4, "x": 0, "y": 0 },
          "targets": [{ "expr": "irc_now_users_total", "legendFormat": "Total" }],
          "fieldConfig": { "defaults": { "thresholds": { "steps": [{ "color": "blue", "value": null }] } } }
        },
        {
          "id": 2,
          "title": "Active Users (24h)",
          "type": "stat",
          "gridPos": { "h": 4, "w": 4, "x": 4, "y": 0 },
          "targets": [{ "expr": "irc_now_active_users_24h", "legendFormat": "DAU" }],
          "fieldConfig": { "defaults": { "thresholds": { "steps": [{ "color": "green", "value": null }] } } }
        },
        {
          "id": 3,
          "title": "Logins",
          "type": "stat",
          "gridPos": { "h": 4, "w": 4, "x": 8, "y": 0 },
          "targets": [{ "expr": "increase(irc_now_logins_total[24h])", "legendFormat": "24h" }],
          "fieldConfig": { "defaults": { "thresholds": { "steps": [{ "color": "purple", "value": null }] } } }
        },
        {
          "id": 4,
          "title": "Users by Plan",
          "type": "piechart",
          "gridPos": { "h": 8, "w": 6, "x": 12, "y": 0 },
          "targets": [{ "expr": "irc_now_users_by_plan", "legendFormat": "{{ plan }}" }]
        },
        {
          "id": 5,
          "title": "Pastes",
          "type": "stat",
          "gridPos": { "h": 4, "w": 4, "x": 0, "y": 4 },
          "targets": [{ "expr": "irc_now_pastes_total", "legendFormat": "Total" }],
          "fieldConfig": { "defaults": { "thresholds": { "steps": [{ "color": "orange", "value": null }] } } }
        },
        {
          "id": 6,
          "title": "Images",
          "type": "stat",
          "gridPos": { "h": 4, "w": 4, "x": 4, "y": 4 },
          "targets": [{ "expr": "irc_now_images_total", "legendFormat": "Total" }],
          "fieldConfig": { "defaults": { "thresholds": { "steps": [{ "color": "yellow", "value": null }] } } }
        },
        {
          "id": 7,
          "title": "Bots",
          "type": "stat",
          "gridPos": { "h": 4, "w": 4, "x": 8, "y": 4 },
          "targets": [{ "expr": "irc_now_bots_total", "legendFormat": "Total" }],
          "fieldConfig": { "defaults": { "thresholds": { "steps": [{ "color": "red", "value": null }] } } }
        },
        {
          "id": 8,
          "title": "Bots Running",
          "type": "gauge",
          "gridPos": { "h": 4, "w": 6, "x": 18, "y": 0 },
          "targets": [{ "expr": "irc_now_bots_running", "legendFormat": "Running" }],
          "fieldConfig": { "defaults": { "max": 10, "thresholds": { "steps": [{ "color": "green", "value": null }, { "color": "yellow", "value": 5 }, { "color": "red", "value": 8 }] } } }
        },
        {
          "id": 9,
          "title": "Users Over Time",
          "type": "timeseries",
          "gridPos": { "h": 8, "w": 12, "x": 0, "y": 8 },
          "targets": [
            { "expr": "irc_now_users_total", "legendFormat": "Total" },
            { "expr": "irc_now_active_users_24h", "legendFormat": "Active (24h)" }
          ]
        },
        {
          "id": 10,
          "title": "Content Over Time",
          "type": "timeseries",
          "gridPos": { "h": 8, "w": 12, "x": 12, "y": 8 },
          "targets": [
            { "expr": "irc_now_pastes_total", "legendFormat": "Pastes" },
            { "expr": "irc_now_images_total", "legendFormat": "Images" },
            { "expr": "irc_now_bots_total", "legendFormat": "Bots" }
          ]
        },
        {
          "id": 11,
          "title": "Storage (Bytes)",
          "type": "timeseries",
          "gridPos": { "h": 8, "w": 12, "x": 0, "y": 16 },
          "targets": [
            { "expr": "irc_now_pastes_storage_bytes", "legendFormat": "Pastes" },
            { "expr": "irc_now_images_storage_bytes", "legendFormat": "Images" }
          ],
          "fieldConfig": { "defaults": { "unit": "bytes" } }
        },
        {
          "id": 12,
          "title": "IRC Bouncer",
          "type": "timeseries",
          "gridPos": { "h": 8, "w": 12, "x": 12, "y": 16 },
          "targets": [
            { "expr": "irc_now_bouncer_networks_total", "legendFormat": "Networks" },
            { "expr": "irc_now_bouncer_channels_total", "legendFormat": "Channels" },
            { "expr": "irc_now_bouncer_active_users", "legendFormat": "Active Users" }
          ]
        },
        {
          "id": 13,
          "title": "HTTP Requests (5m rate)",
          "type": "timeseries",
          "gridPos": { "h": 8, "w": 12, "x": 0, "y": 24 },
          "targets": [
            { "expr": "sum(rate(http_requests_total{namespace=\"irc-josie-cloud\"}[5m])) by (job)", "legendFormat": "{{ job }}" }
          ],
          "fieldConfig": { "defaults": { "unit": "reqps" } }
        },
        {
          "id": 14,
          "title": "HTTP Latency p95",
          "type": "timeseries",
          "gridPos": { "h": 8, "w": 12, "x": 12, "y": 24 },
          "targets": [
            { "expr": "histogram_quantile(0.95, sum(rate(http_request_duration_seconds{namespace=\"irc-josie-cloud\"}[5m])) by (job, le))", "legendFormat": "{{ job }}" }
          ],
          "fieldConfig": { "defaults": { "unit": "s" } }
        },
        {
          "id": 15,
          "title": "MRR",
          "type": "stat",
          "gridPos": { "h": 4, "w": 4, "x": 18, "y": 4 },
          "targets": [{ "expr": "irc_now_mrr_cents / 100", "legendFormat": "MRR" }],
          "fieldConfig": { "defaults": { "unit": "currencyUSD", "thresholds": { "steps": [{ "color": "green", "value": null }] } } }
        },
        {
          "id": 16,
          "title": "Subscriptions",
          "type": "stat",
          "gridPos": { "h": 4, "w": 3, "x": 22, "y": 4 },
          "targets": [{ "expr": "irc_now_subscriptions_active", "legendFormat": "Active" }],
          "fieldConfig": { "defaults": { "thresholds": { "steps": [{ "color": "green", "value": null }] } } }
        },
        {
          "id": 17,
          "title": "Signups (7d)",
          "type": "stat",
          "gridPos": { "h": 4, "w": 4, "x": 12, "y": 4 },
          "targets": [{ "expr": "irc_now_signups_7d", "legendFormat": "7d" }],
          "fieldConfig": { "defaults": { "thresholds": { "steps": [{ "color": "blue", "value": null }] } } }
        },
        {
          "id": 18,
          "title": "Conversion Rate (30d)",
          "type": "stat",
          "gridPos": { "h": 4, "w": 6, "x": 0, "y": 32 },
          "targets": [{ "expr": "irc_now_conversion_rate_30d * 100", "legendFormat": "Rate" }],
          "fieldConfig": { "defaults": { "unit": "percent", "thresholds": { "steps": [{ "color": "yellow", "value": null }, { "color": "green", "value": 5 }] } } }
        },
        {
          "id": 19,
          "title": "Churn Rate (30d)",
          "type": "stat",
          "gridPos": { "h": 4, "w": 6, "x": 6, "y": 32 },
          "targets": [{ "expr": "irc_now_churn_rate_30d * 100", "legendFormat": "Rate" }],
          "fieldConfig": { "defaults": { "unit": "percent", "thresholds": { "steps": [{ "color": "green", "value": null }, { "color": "yellow", "value": 5 }, { "color": "red", "value": 10 }] } } }
        },
        {
          "id": 20,
          "title": "Revenue Over Time",
          "type": "timeseries",
          "gridPos": { "h": 8, "w": 12, "x": 12, "y": 32 },
          "targets": [
            { "expr": "irc_now_mrr_cents / 100", "legendFormat": "MRR" },
            { "expr": "irc_now_subscriptions_active", "legendFormat": "Subscriptions" }
          ],
          "fieldConfig": { "defaults": { "unit": "currencyUSD" } }
        }
      ],
      "schemaVersion": 39
    }
