{
  "uid": "fak-startup-load",
  "title": "FAK Startup & Model Load",
  "description": "The one-time boot sequence of a fak gateway: time-to-ready, per-phase boot cost, and the GGUF weight-load breakdown. Source: fak serve /metrics (fak_gateway_startup_* and fak_model_load_* gauges). Populate the model-load panels with: fak serve --gguf MODEL.gguf.",
  "tags": [
    "fak",
    "gateway",
    "startup",
    "model-load"
  ],
  "editable": true,
  "fiscalYearStartMonth": 0,
  "graphTooltip": 1,
  "schemaVersion": 39,
  "version": 1,
  "refresh": "30s",
  "time": {
    "from": "now-6h",
    "to": "now"
  },
  "timepicker": {},
  "links": [],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": {
          "type": "grafana",
          "uid": "-- Grafana --"
        },
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "templating": {
    "list": [
      {
        "name": "DS_PROMETHEUS",
        "label": "Prometheus",
        "type": "datasource",
        "query": "prometheus",
        "current": {},
        "hide": 2,
        "refresh": 1,
        "regex": "",
        "options": [],
        "includeAll": false,
        "multi": false
      }
    ]
  },
  "panels": [
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "First run: the Model weight load panels need --gguf",
      "description": "Why the model-load panels read No data on a fresh up.sh stack (no --gguf), and what to run to populate them.",
      "type": "text",
      "id": 69,
      "gridPos": {
        "h": 5,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "fieldConfig": {
        "defaults": {},
        "overrides": []
      },
      "options": {
        "mode": "markdown",
        "content": "The default `tools/grafana/up.sh` path starts the gateway with `--engine inkernel --model smollm2-135m` against a fak-format export, with **no `--gguf`** - so every `fak_model_load_*` panel (Model load time, Weights loaded, Tensors, the GGUF phase bargauges, and the Loaded model table) stays **No data**. Emitted only when `fak serve` is started with `--gguf`. The default `up.sh` path uses the inkernel engine against a fak-format export, so these stay empty unless you re-launch with `--gguf MODEL.gguf`.\n\nThe Boot summary tiles and the Startup phase breakdown DO populate on the up.sh path - they time every gateway boot regardless of weights. Only the GGUF weight-load section is `--gguf`-gated."
      },
      "pluginVersion": "11.5.2"
    },
    {
      "type": "row",
      "title": "Boot summary",
      "id": 70,
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 5
      },
      "panels": []
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Time to ready",
      "description": "Total wall-clock from process start to the gateway becoming ready to serve (socket bound). 0 until the boot completes.",
      "type": "stat",
      "id": 71,
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 0,
        "y": 6
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "yellow",
                "value": 5
              },
              {
                "color": "red",
                "value": 30
              }
            ]
          },
          "unit": "s"
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "textMode": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "fak_gateway_time_to_ready_seconds",
          "refId": "A"
        }
      ]
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Boot unaccounted",
      "description": "Boot wall-clock the named phases do NOT explain (time_to_ready minus the sum of phase durations). Near-zero means startup is FULLY instrumented; a non-zero value means a phase is missing or work ran between New and MarkReady that no phase records.",
      "type": "stat",
      "id": 72,
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 6,
        "y": 6
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "yellow",
                "value": 0.05
              },
              {
                "color": "red",
                "value": 0.5
              }
            ]
          },
          "unit": "s"
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "textMode": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "fak_gateway_startup_unaccounted_seconds",
          "refId": "A"
        }
      ]
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Gateway up",
      "description": "Self-reported gateway liveness.",
      "type": "stat",
      "id": 73,
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 12,
        "y": 6
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [
            {
              "type": "value",
              "options": {
                "0": {
                  "text": "DOWN",
                  "color": "red",
                  "index": 0
                },
                "1": {
                  "text": "UP",
                  "color": "green",
                  "index": 1
                }
              }
            }
          ],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "red",
                "value": null
              },
              {
                "color": "green",
                "value": 1
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "textMode": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "fak_gateway_up",
          "refId": "A"
        }
      ]
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Uptime",
      "description": "Time since this gateway process started.",
      "type": "stat",
      "id": 74,
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 18,
        "y": 6
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "unit": "s"
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "textMode": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "time() - fak_gateway_start_time_seconds",
          "refId": "A"
        }
      ]
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Model load time",
      "description": "Total wall-clock to load model weights at boot. No data when serving with no --gguf weights. Emitted only when `fak serve` is started with `--gguf`. The default `up.sh` path uses the inkernel engine against a fak-format export, so these stay empty unless you re-launch with `--gguf MODEL.gguf`.",
      "type": "stat",
      "id": 75,
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 0,
        "y": 10
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "yellow",
                "value": 5
              },
              {
                "color": "red",
                "value": 30
              }
            ]
          },
          "unit": "s"
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "textMode": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "fak_model_load_duration_seconds",
          "refId": "A"
        }
      ]
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Weights loaded",
      "description": "Total bytes read/materialized while loading weights at boot. Emitted only when `fak serve` is started with `--gguf`. The default `up.sh` path uses the inkernel engine against a fak-format export, so these stay empty unless you re-launch with `--gguf MODEL.gguf`.",
      "type": "stat",
      "id": 76,
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 6,
        "y": 10
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "blue",
                "value": null
              }
            ]
          },
          "unit": "bytes"
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "textMode": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "fak_model_load_bytes",
          "refId": "A"
        }
      ]
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Tensors",
      "description": "Tensors materialized while loading weights at boot. Emitted only when `fak serve` is started with `--gguf`. The default `up.sh` path uses the inkernel engine against a fak-format export, so these stay empty unless you re-launch with `--gguf MODEL.gguf`.",
      "type": "stat",
      "id": 77,
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 12,
        "y": 10
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "blue",
                "value": null
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "textMode": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "fak_model_load_tensors",
          "refId": "A"
        }
      ]
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Ready at",
      "description": "Unix instant (ms) the gateway became ready to serve.",
      "type": "stat",
      "id": 78,
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 18,
        "y": 10
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "blue",
                "value": null
              }
            ]
          },
          "unit": "none"
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "textMode": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "fak_gateway_ready_time_seconds * 1000",
          "refId": "A"
        }
      ]
    },
    {
      "type": "row",
      "title": "Startup phase breakdown",
      "id": 79,
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 14
      },
      "panels": []
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Boot phase cost (now)",
      "description": "Wall-clock of each boot phase, bottleneck first: flag-parse, policy-load, planner-init, vdso-config, kernel-init, listener-bind, and model-load (with --gguf). The listener-bind phase is measured on the synchronous net.Listen, so it is accurate to the moment the socket is ready.",
      "type": "bargauge",
      "id": 80,
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 15
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "unit": "s"
        },
        "overrides": []
      },
      "options": {
        "displayMode": "gradient",
        "orientation": "horizontal",
        "showUnfilled": true,
        "minVizHeight": 10,
        "minVizWidth": 0,
        "valueMode": "color",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "sort_desc(fak_gateway_startup_phase_duration_seconds)",
          "legendFormat": "{{phase}}",
          "instant": true,
          "refId": "A"
        }
      ]
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Time to ready over restarts",
      "description": "Both gauges hold their once-at-boot values, so each fresh process shows as a new level \u2014 restarts and their boot cost are visible across the window. unaccounted tracking time-to-ready means a phase is missing.",
      "type": "timeseries",
      "id": 81,
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 15
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "drawStyle": "line",
            "lineWidth": 1,
            "fillOpacity": 10,
            "showPoints": "never",
            "axisPlacement": "auto",
            "spanNulls": true,
            "pointSize": 5,
            "stacking": {
              "mode": "none"
            }
          },
          "unit": "s",
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          }
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "calcs": []
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "fak_gateway_time_to_ready_seconds",
          "legendFormat": "time to ready",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "fak_gateway_startup_unaccounted_seconds",
          "legendFormat": "unaccounted",
          "refId": "B"
        }
      ]
    },
    {
      "type": "row",
      "title": "Model weight load (GGUF phases)",
      "id": 82,
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 23
      },
      "panels": []
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Load phase time (bottleneck first)",
      "description": "Wall-clock of each GGUF weight-load phase. The top bar is the bottleneck. Empty until a gateway is started with --gguf. Emitted only when `fak serve` is started with `--gguf`. The default `up.sh` path uses the inkernel engine against a fak-format export, so these stay empty unless you re-launch with `--gguf MODEL.gguf`.",
      "type": "bargauge",
      "id": 83,
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 24
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "unit": "s"
        },
        "overrides": []
      },
      "options": {
        "displayMode": "gradient",
        "orientation": "horizontal",
        "showUnfilled": true,
        "minVizHeight": 10,
        "minVizWidth": 0,
        "valueMode": "color",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "sort_desc(fak_model_load_phase_duration_seconds)",
          "legendFormat": "{{phase}}",
          "instant": true,
          "refId": "A"
        }
      ]
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Load phase bytes",
      "description": "Bytes processed by each GGUF weight-load phase. Emitted only when `fak serve` is started with `--gguf`. The default `up.sh` path uses the inkernel engine against a fak-format export, so these stay empty unless you re-launch with `--gguf MODEL.gguf`.",
      "type": "bargauge",
      "id": 84,
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 24
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "unit": "bytes"
        },
        "overrides": []
      },
      "options": {
        "displayMode": "gradient",
        "orientation": "horizontal",
        "showUnfilled": true,
        "minVizHeight": 10,
        "minVizWidth": 0,
        "valueMode": "color",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "sort_desc(fak_model_load_phase_bytes)",
          "legendFormat": "{{phase}}",
          "instant": true,
          "refId": "A"
        }
      ]
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Loaded model",
      "description": "Static labels for the model loaded at boot: source path, loader mode, and the slowest (bottleneck) load phase. Empty with no --gguf weights. Emitted only when `fak serve` is started with `--gguf`. The default `up.sh` path uses the inkernel engine against a fak-format export, so these stay empty unless you re-launch with `--gguf MODEL.gguf`.",
      "type": "table",
      "id": 85,
      "gridPos": {
        "h": 6,
        "w": 24,
        "x": 0,
        "y": 32
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "custom": {
            "align": "auto",
            "cellOptions": {
              "type": "auto"
            },
            "inspect": false
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          }
        },
        "overrides": []
      },
      "options": {
        "showHeader": true,
        "cellHeight": "sm",
        "footer": {
          "show": false,
          "reducer": [
            "sum"
          ],
          "fields": ""
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "fak_model_load_info",
          "format": "table",
          "instant": true,
          "refId": "A"
        }
      ],
      "transformations": [
        {
          "id": "organize",
          "options": {
            "excludeByName": {
              "Time": true,
              "Value": true,
              "__name__": true,
              "job": true,
              "instance": true
            },
            "renameByName": {}
          }
        }
      ]
    }
  ]
}
