Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

116 KB
Raw Blame
{
    "annotations": {
        "list": [
            {
                "builtIn": 1,
                "datasource": {
                    "type": "grafana",
                    "uid": "-- Grafana --"
                },
                "enable": true,
                "hide": true,
                "iconColor": "rgba(0, 211, 255, 1)",
                "name": "Annotations & Alerts",
                "type": "dashboard"
            }
        ]
    },
    "description": "Notebook errors and SQLV2 frame-store rollout. The first two rows answer 'what is breaking for users, in the app and via MCP'. The rows below them answer 'is the frame-store rollout going well'. Prometheus/VictoriaMetrics only: ClickHouse per-query cost lives in query_log_archive, see observability/notebooks-query-log.sql, and per-run error text lives in Postgres.",
    "editable": true,
    "fiscalYearStartMonth": 0,
    "graphTooltip": 0,
    "links": [],
    "panels": [
        {
            "collapsed": false,
            "gridPos": {
                "h": 1,
                "w": 24,
                "x": 0,
                "y": 0
            },
            "id": 1,
            "panels": [],
            "title": "Errors \u2014 what a user actually hits",
            "type": "row"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "Every run that did not reach `done`, split by cell type. `hogql` is a SQL cell on the direct lane. `python` is a Python cell in the sandbox. `duckdb` is a SQL cell rerouted to the sandbox because it reads a local frame. The Run outcomes panel further down sums these together, so a Python-only regression hides there.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green"
                            }
                        ]
                    },
                    "unit": "reqps"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 8,
                "x": 0,
                "y": 1
            },
            "id": 2,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "sum by (node_type, outcome) (rate(posthog_notebooks_node_run_seconds_count{outcome!=\"done\"}[$__rate_interval]))",
                    "legendFormat": "{{node_type}} {{outcome}}",
                    "range": true,
                    "refId": "A"
                }
            ],
            "title": "Failing cells by type",
            "type": "timeseries"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "Share of runs that broke, per cell type. `interrupted` is excluded: a user who cancels a slow query is not an error. Read this next to the panel on the left. A rising rate with a flat ratio means more traffic, not more breakage.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "min": 0,
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green"
                            },
                            {
                                "color": "yellow",
                                "value": 0.05
                            },
                            {
                                "color": "red",
                                "value": 0.2
                            }
                        ]
                    },
                    "unit": "percentunit"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 8,
                "x": 8,
                "y": 1
            },
            "id": 3,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "sum by (node_type) (rate(posthog_notebooks_node_run_seconds_count{outcome=~\"failed|timed_out\"}[$__rate_interval])) / clamp_min(sum by (node_type) (rate(posthog_notebooks_node_run_seconds_count[$__rate_interval])), 1e-9)",
                    "legendFormat": "{{node_type}}",
                    "range": true,
                    "refId": "A"
                }
            ],
            "title": "Cell failure ratio by type",
            "type": "timeseries"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "Non-2xx responses from the explicit kernel buttons. `kernel/start` and `kernel/restart` return 503 when the sandbox fails to provision. This covers only the button path. A SQLV2 run provisions its own kernel inside the Temporal dispatch activity, and that failure arrives as a plain failed run in the panels to the left, carrying the error text `Run failed to dispatch to the kernel.` Verify the `view` label values before trusting the regex.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green"
                            }
                        ]
                    },
                    "unit": "reqps"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 8,
                "x": 16,
                "y": 1
            },
            "id": 4,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "sum by (view, status_class) (rate(posthog_api_requests_latency_seconds_count{view=~\".*kernel-(start|restart)\", status_class!=\"2xx\"}[$__rate_interval]))",
                    "legendFormat": "{{view}} {{status_class}}",
                    "range": true,
                    "refId": "A"
                }
            ],
            "title": "Kernel start and restart failures",
            "type": "timeseries"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "Three phases the kernel lane reports back from the sandbox. `kernel_boot` is near zero when the kernel is already warm, so a rise means runs are paying for a cold sandbox. `input_wait` and `download` cover fetching referenced frames over presigned URLs. Both rising is the documented rollout hazard: `OBJECT_STORAGE_PUBLIC_ENDPOINT` must resolve from the sandbox's own network. All three are success biased. A kernel that never boots delivers no envelope and therefore no sample.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green"
                            }
                        ]
                    },
                    "unit": "s"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 8,
                "x": 0,
                "y": 9
            },
            "id": 5,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "histogram_quantile(0.95, sum by (le, phase) (rate(posthog_notebooks_node_run_phase_seconds_bucket{phase=~\"kernel_boot|input_wait|download\"}[$__rate_interval])))",
                    "legendFormat": "p95 {{phase}}",
                    "range": true,
                    "refId": "A"
                }
            ],
            "title": "Kernel boot and frame fetch p95",
            "type": "timeseries"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "Failed requests on the user-facing REST surface, by endpoint. This is where creating, saving, and reading a notebook breaks. A 4xx on the markdown save action includes the 409 conflict two concurrent editors produce. `status_class=error` means the view raised before it produced a response.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green"
                            }
                        ]
                    },
                    "unit": "reqps"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 8,
                "x": 8,
                "y": 9
            },
            "id": 6,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "sum by (view, status_class) (rate(posthog_api_requests_latency_seconds_count{view=~\".*notebook.*\", status_class=~\"4xx|5xx|error\"}[$__rate_interval]))",
                    "legendFormat": "{{view}} {{status_class}}",
                    "range": true,
                    "refId": "A"
                }
            ],
            "title": "Notebook API errors by view",
            "type": "timeseries"
        },
        {
            "gridPos": {
                "h": 8,
                "w": 8,
                "x": 16,
                "y": 9
            },
            "id": 7,
            "options": {
                "content": "Three failure modes never reach Prometheus. Each has a query instead.\n\n**Why a run failed.** `run.error` is free text and never becomes a label, so Grafana shows the rate and not the cause. Postgres:\n\n```sql\nSELECT node_type, error, count(*)\nFROM posthog_notebooknoderun\nWHERE team_id = <id>\n  AND status = 'failed'\n  AND created_at > now() - interval '6 hours'\nGROUP BY 1, 2 ORDER BY 3 DESC;\n```\n\nClosing this in Grafana needs an `error_kind` label on `record_node_run_terminal` (`backend/sql_v2_metrics.py`).\n\n**Stranded runs.** A sandbox that dies without delivering its callback leaves the row RUNNING forever and emits no sample, so a lost kernel run is missing from every histogram here.\n\n```sql\nSELECT count(*) FROM posthog_notebooknoderun\nWHERE status = 'running' AND created_at < now() - interval '1 hour';\n```\n\n**Per-notebook and per-user failures.** Product analytics, not Prometheus. The `notebook node run completed` event carries `notebook_short_id`, `node_type`, `outcome`, `delivery`, and the phase seconds.",
                "mode": "markdown"
            },
            "title": "What no panel in this row can see",
            "type": "text"
        },
        {
            "collapsed": false,
            "gridPos": {
                "h": 1,
                "w": 24,
                "x": 0,
                "y": 17
            },
            "id": 8,
            "panels": [],
            "title": "MCP \u2014 notebook tools called by agents",
            "type": "row"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "Tool dispatches on the hono MCP server, for the notebook tools enabled in `products/notebooks/mcp/tools.yaml`. A `validation_error` means the agent sent arguments the schema rejected, which is a tool description problem rather than an outage. Calls routed through `exec` report the real inner tool name, so both call shapes land here.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green"
                            }
                        ]
                    },
                    "unit": "reqps"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 12,
                "x": 0,
                "y": 18
            },
            "id": 9,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "sum by (tool, status) (rate(mcp_tool_calls_total{tool=~\"notebooks-.*\"}[$__rate_interval]))",
                    "legendFormat": "{{tool}} {{status}}",
                    "range": true,
                    "refId": "A"
                }
            ],
            "title": "Notebook MCP tool calls by outcome",
            "type": "timeseries"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "Why each notebook tool failed. `api_4xx` and `api_5xx` come from the Django endpoint behind the tool, so pair them with the API panels below. `validation`, `permission`, and `missing_context` are the agent's own call. `rate_limited` and `timeout` are load.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green"
                            }
                        ]
                    },
                    "unit": "reqps"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 12,
                "x": 12,
                "y": 18
            },
            "id": 10,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "sum by (tool, error_type) (rate(mcp_tool_errors_total{tool=~\"notebooks-.*\"}[$__rate_interval]))",
                    "legendFormat": "{{tool}} {{error_type}}",
                    "range": true,
                    "refId": "A"
                }
            ],
            "title": "Notebook MCP tool errors by type",
            "type": "timeseries"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "Share of notebook tool dispatches that did not succeed. Schema rejections count, and they dominate when a tool description is unclear.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "min": 0,
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green"
                            },
                            {
                                "color": "yellow",
                                "value": 0.05
                            },
                            {
                                "color": "red",
                                "value": 0.15
                            }
                        ]
                    },
                    "unit": "percentunit"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 4,
                "x": 0,
                "y": 26
            },
            "id": 11,
            "options": {
                "colorMode": "value",
                "graphMode": "area",
                "justifyMode": "auto",
                "orientation": "auto",
                "reduceOptions": {
                    "calcs": ["lastNotNull"],
                    "fields": "",
                    "values": false
                },
                "textMode": "auto"
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "sum(rate(mcp_tool_calls_total{tool=~\"notebooks-.*\",status!=\"success\"}[$__rate_interval])) / clamp_min(sum(rate(mcp_tool_calls_total{tool=~\"notebooks-.*\"}[$__rate_interval])), 1e-9)",
                    "legendFormat": "failed",
                    "range": true,
                    "refId": "A"
                }
            ],
            "title": "MCP tool failure ratio",
            "type": "stat"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "Time inside the MCP server per notebook tool dispatch, including its call to the PostHog API. Schema rejections are never timed, so this measures the calls that reached a handler.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green"
                            }
                        ]
                    },
                    "unit": "s"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 10,
                "x": 4,
                "y": 26
            },
            "id": 12,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "histogram_quantile(0.95, sum by (le, tool) (rate(mcp_tool_call_duration_seconds_bucket{tool=~\"notebooks-.*\"}[$__rate_interval])))",
                    "legendFormat": "p95 {{tool}}",
                    "range": true,
                    "refId": "A"
                }
            ],
            "title": "Notebook MCP tool latency p95",
            "type": "timeseries"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "The same notebook API requests as the HTTP row, split by who called. `web` is a browser session. `mcp` is the MCP server. `cli`, `posthog_code`, and `wizard` are the tools that wrap it. `api` is a bare personal API key. Every other API panel on this dashboard averages these callers together.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green"
                            }
                        ]
                    },
                    "unit": "reqps"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 10,
                "x": 14,
                "y": 26
            },
            "id": 13,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "sum by (source, status_class) (rate(posthog_api_requests_latency_seconds_count{view=~\".*notebook.*\"}[$__rate_interval]))",
                    "legendFormat": "{{source}} {{status_class}}",
                    "range": true,
                    "refId": "A"
                }
            ],
            "title": "Notebooks API \u2014 agent vs browser",
            "type": "timeseries"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "Agents fail differently from people. A 4xx heavy `mcp` line points at tool schemas or a wrong short_id. A 5xx heavy one is ours. Compare against `web` to tell a notebook problem from an agent problem.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "min": 0,
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green"
                            }
                        ]
                    },
                    "unit": "percentunit"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 12,
                "x": 0,
                "y": 34
            },
            "id": 14,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "sum by (source) (rate(posthog_api_requests_latency_seconds_count{view=~\".*notebook.*\", status_class=~\"4xx|5xx|error\"}[$__rate_interval])) / clamp_min(sum by (source) (rate(posthog_api_requests_latency_seconds_count{view=~\".*notebook.*\"}[$__rate_interval])), 1e-9)",
                    "legendFormat": "{{source}}",
                    "range": true,
                    "refId": "A"
                }
            ],
            "title": "Notebooks API failure ratio by caller",
            "type": "timeseries"
        },
        {
            "gridPos": {
                "h": 8,
                "w": 12,
                "x": 12,
                "y": 34
            },
            "id": 15,
            "options": {
                "content": "**CLI mode is not on this dashboard.** `posthog-cli` and the MCP CLI run on the user's own machine and export no Prometheus metrics. Their tool calls reach PostHog events only. Use the `$mcp_tool_call` event, or the MCP analytics product, and filter to the notebook tools.\n\n**Confirm the scrape before reading zero as calm.** The `mcp_*` series come from the hono MCP server, a different deployment from the Django app behind every other panel here. Check that `mcp_http_requests_total` has data at all before concluding a notebook tool is unused.\n\n**Verify the `view` label.** The notebook API paths set no `name=` in `urls.py`, so Django derives the view name. Confirm the real values with `list_prometheus_label_values` before trusting any `view=~` regex on this dashboard.",
                "mode": "markdown"
            },
            "title": "MCP blind spots \u2014 read before concluding a tool is healthy",
            "type": "text"
        },
        {
            "collapsed": false,
            "gridPos": {
                "h": 1,
                "w": 24,
                "x": 0,
                "y": 42
            },
            "id": 16,
            "panels": [],
            "title": "Node runs \u2014 end to end (every run, every outcome)",
            "type": "row"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "End to end: run-row creation to the terminal transition (callback, direct-lane finish, or interrupt). Unlike the frame histograms below, every terminal outcome contributes a sample \u2014 but a kernel run whose sandbox callback is lost stays RUNNING and is missing here until re-run.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green"
                            }
                        ]
                    },
                    "unit": "s"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 8,
                "x": 0,
                "y": 43
            },
            "id": 17,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "histogram_quantile(0.95, sum by (le, node_type) (rate(posthog_notebooks_node_run_seconds_bucket[$__rate_interval])))",
                    "legendFormat": "p95 {{node_type}}",
                    "range": true,
                    "refId": "A"
                },
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "histogram_quantile(0.50, sum by (le, node_type) (rate(posthog_notebooks_node_run_seconds_bucket[$__rate_interval])))",
                    "legendFormat": "p50 {{node_type}}",
                    "range": true,
                    "refId": "B"
                }
            ],
            "title": "Node run duration p50/p95, by node type",
            "type": "timeseries"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "done / failed / interrupted / timed_out. timed_out comes from the direct lane's grace-expiry watchdog \u2014 a rising timed_out rate means queries are expiring in the async manager, not that users are writing bad queries.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green"
                            }
                        ]
                    },
                    "unit": "ops"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 8,
                "x": 8,
                "y": 43
            },
            "id": 18,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "sum by (outcome) (rate(posthog_notebooks_node_run_seconds_count[$__rate_interval]))",
                    "legendFormat": "{{outcome}}",
                    "range": true,
                    "refId": "A"
                }
            ],
            "title": "Run outcomes",
            "type": "timeseries"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "queued: enqueue to Celery pickup (direct lane). clickhouse: pickup to completion, HogQL compile + CH execution (direct lane). input_wait: sandbox waiting on the data plane for referenced frames. download: presigned frame downloads. exec: ipykernel cell execution. sandbox_total: the whole sandbox-side run.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green"
                            }
                        ]
                    },
                    "unit": "s"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 8,
                "x": 16,
                "y": 43
            },
            "id": 19,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "histogram_quantile(0.95, sum by (le, phase) (rate(posthog_notebooks_node_run_phase_seconds_bucket[$__rate_interval])))",
                    "legendFormat": "p95 {{phase}}",
                    "range": true,
                    "refId": "A"
                }
            ],
            "title": "Where the time goes \u2014 phase p95",
            "type": "timeseries"
        },
        {
            "collapsed": false,
            "gridPos": {
                "h": 1,
                "w": 24,
                "x": 0,
                "y": 51
            },
            "id": 45,
            "panels": [],
            "title": "Temporal queue \u2014 general-purpose-task-queue (shared with other products)",
            "type": "row"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "Tasks that Temporal Cloud holds for this queue because no poller is free. Every notebook workflow and activity runs on this queue, and other products share it. A sustained backlog delays notebook runs when the notebooks code is healthy. The worker fleet has a fixed pod count, so a backlog does not add workers.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "min": 0,
                    "unit": "short"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 8,
                "x": 0,
                "y": 52
            },
            "id": 46,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "max by (task_type) (temporal_cloud_v1_approximate_backlog_count{temporal_task_queue=\"general-purpose-task-queue\"})",
                    "legendFormat": "{{task_type}}",
                    "range": true,
                    "refId": "A"
                }
            ],
            "title": "Queue backlog by task type",
            "type": "timeseries"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "Share of tasks whose schedule-to-start latency is over the bucket edge, measured by the SDK on the worker. The SDK histogram has coarse millisecond buckets (100, 500, 1000, 5000, 10000, 100000), so this panel shows a share over an edge and not a percentile. The series has no workflow_type or activity_type label, so it covers the whole queue. The materialize activity has a 10-minute schedule_to_close timeout that includes this wait, so a long wait uses up that deadline.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "min": 0,
                    "unit": "percentunit"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 8,
                "x": 8,
                "y": 52
            },
            "id": 47,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "clamp_min((sum(rate(temporal_activity_schedule_to_start_latency_count{task_queue=\"general-purpose-task-queue\"}[$__rate_interval])) - sum(rate(temporal_activity_schedule_to_start_latency_bucket{task_queue=\"general-purpose-task-queue\",le=\"1000\"}[$__rate_interval]))) / clamp_min(sum(rate(temporal_activity_schedule_to_start_latency_count{task_queue=\"general-purpose-task-queue\"}[$__rate_interval])), 1e-9), 0)",
                    "legendFormat": "activity tasks > 1s",
                    "range": true,
                    "refId": "A"
                },
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "clamp_min((sum(rate(temporal_activity_schedule_to_start_latency_count{task_queue=\"general-purpose-task-queue\"}[$__rate_interval])) - sum(rate(temporal_activity_schedule_to_start_latency_bucket{task_queue=\"general-purpose-task-queue\",le=\"10000\"}[$__rate_interval]))) / clamp_min(sum(rate(temporal_activity_schedule_to_start_latency_count{task_queue=\"general-purpose-task-queue\"}[$__rate_interval])), 1e-9), 0)",
                    "legendFormat": "activity tasks > 10s",
                    "range": true,
                    "refId": "B"
                },
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "clamp_min((sum(rate(temporal_workflow_task_schedule_to_start_latency_count{task_queue=\"general-purpose-task-queue\"}[$__rate_interval])) - sum(rate(temporal_workflow_task_schedule_to_start_latency_bucket{task_queue=\"general-purpose-task-queue\",le=\"1000\"}[$__rate_interval]))) / clamp_min(sum(rate(temporal_workflow_task_schedule_to_start_latency_count{task_queue=\"general-purpose-task-queue\"}[$__rate_interval])), 1e-9), 0)",
                    "legendFormat": "workflow tasks > 1s",
                    "range": true,
                    "refId": "C"
                },
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "clamp_min((sum(rate(temporal_workflow_task_schedule_to_start_latency_count{task_queue=\"general-purpose-task-queue\"}[$__rate_interval])) - sum(rate(temporal_workflow_task_schedule_to_start_latency_bucket{task_queue=\"general-purpose-task-queue\",le=\"10000\"}[$__rate_interval]))) / clamp_min(sum(rate(temporal_workflow_task_schedule_to_start_latency_count{task_queue=\"general-purpose-task-queue\"}[$__rate_interval])), 1e-9), 0)",
                    "legendFormat": "workflow tasks > 10s",
                    "range": true,
                    "refId": "D"
                }
            ],
            "title": "Tasks that wait over 1s and 10s for a worker",
            "type": "timeseries"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "Share of tasks that Temporal Cloud gave directly to a waiting poller, with no stop in the backlog. Near 100% means the workers keep up. This ratio drops before a backlog becomes visible, so read it first. Temporal Cloud series are per-second rates sampled each minute, so the expression divides them directly and must not use rate(). A minute with no tasks shows no data.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "custom": {
                        "thresholdsStyle": {
                            "mode": "line"
                        }
                    },
                    "max": 1,
                    "min": 0,
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "red",
                                "value": null
                            },
                            {
                                "color": "yellow",
                                "value": 0.9
                            },
                            {
                                "color": "green",
                                "value": 0.99
                            }
                        ]
                    },
                    "unit": "percentunit"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 8,
                "x": 16,
                "y": 52
            },
            "id": 48,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "sum by (task_type) (temporal_cloud_v1_poll_success_sync_count{temporal_task_queue=\"general-purpose-task-queue\"}) / sum by (task_type) (temporal_cloud_v1_poll_success_count{temporal_task_queue=\"general-purpose-task-queue\"})",
                    "legendFormat": "{{task_type}}",
                    "range": true,
                    "refId": "A"
                }
            ],
            "title": "Sync match ratio (Temporal Cloud)",
            "type": "timeseries"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "Used slots divided by all slots on the general-purpose workers, for workflow tasks and activity tasks. The fleet line shows the total headroom. The busiest-pod line shows one pod at its limit while the fleet still has room. A pod with no free slot stops polling for that task type, and new tasks go to the backlog.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "custom": {
                        "thresholdsStyle": {
                            "mode": "line"
                        }
                    },
                    "max": 1,
                    "min": 0,
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green",
                                "value": null
                            },
                            {
                                "color": "yellow",
                                "value": 0.8
                            },
                            {
                                "color": "red",
                                "value": 0.95
                            }
                        ]
                    },
                    "unit": "percentunit"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 8,
                "x": 0,
                "y": 60
            },
            "id": 49,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "sum by (worker_type) (temporal_worker_task_slots_used{task_queue=\"general-purpose-task-queue\",worker_type=~\"WorkflowWorker|ActivityWorker\"}) / clamp_min(sum by (worker_type) (temporal_worker_task_slots_used{task_queue=\"general-purpose-task-queue\",worker_type=~\"WorkflowWorker|ActivityWorker\"} + temporal_worker_task_slots_available{task_queue=\"general-purpose-task-queue\",worker_type=~\"WorkflowWorker|ActivityWorker\"}), 1)",
                    "legendFormat": "fleet {{worker_type}}",
                    "range": true,
                    "refId": "A"
                },
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "max by (worker_type) (temporal_worker_task_slots_used{task_queue=\"general-purpose-task-queue\",worker_type=~\"WorkflowWorker|ActivityWorker\"} / clamp_min(temporal_worker_task_slots_used{task_queue=\"general-purpose-task-queue\",worker_type=~\"WorkflowWorker|ActivityWorker\"} + temporal_worker_task_slots_available{task_queue=\"general-purpose-task-queue\",worker_type=~\"WorkflowWorker|ActivityWorker\"}, 1))",
                    "legendFormat": "busiest pod {{worker_type}}",
                    "range": true,
                    "refId": "B"
                }
            ],
            "title": "Worker slot usage \u2014 fleet and busiest pod",
            "type": "timeseries"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "Failed activity attempts by activity type, measured by the SDK. Every failed attempt counts, including an attempt that a later retry recovers. A materialize attempt that the concurrency limiter rejects is retryable and also counts here. Compare with the \"Retry amplification\" stat before you treat a rise as an outage.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "min": 0,
                    "unit": "ops"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 8,
                "x": 8,
                "y": 60
            },
            "id": 50,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "sum by (activity_type) (rate(temporal_activity_execution_failed{task_queue=\"general-purpose-task-queue\",activity_type=~\"notebook-.*\"}[$__rate_interval]))",
                    "legendFormat": "{{activity_type}}",
                    "range": true,
                    "refId": "A"
                }
            ],
            "title": "Notebook activity attempt failures",
            "type": "timeseries"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "Workflow executions that reach an end state, by workflow type, measured by the SDK. At low volume, one run shows as a short spike. Select a longer time range to compare rates.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "min": 0,
                    "unit": "ops"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 8,
                "x": 16,
                "y": 60
            },
            "id": 51,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "sum by (workflow_type) (rate(temporal_workflow_completed{task_queue=\"general-purpose-task-queue\",workflow_type=~\"notebook-.*\"}[$__rate_interval]))",
                    "legendFormat": "{{workflow_type}} completed",
                    "range": true,
                    "refId": "A"
                },
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "sum by (workflow_type) (rate(temporal_workflow_failed{task_queue=\"general-purpose-task-queue\",workflow_type=~\"notebook-.*\"}[$__rate_interval]))",
                    "legendFormat": "{{workflow_type}} failed",
                    "range": true,
                    "refId": "B"
                }
            ],
            "title": "Notebook workflow outcomes",
            "type": "timeseries"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "Workflow task failures for every workflow on the queue. The series has no workflow_type label, so this panel cannot isolate notebooks. Temporal retries a failed workflow task with no limit, so the run stops and reports no failure. A step up right after a deploy that changes a notebooks workflow body can be a non-determinism error. Find the run in the Temporal UI to confirm.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "min": 0,
                    "unit": "ops"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 12,
                "x": 0,
                "y": 68
            },
            "id": 52,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "sum by (failure_reason) (rate(temporal_workflow_task_execution_failed{task_queue=\"general-purpose-task-queue\"}[$__rate_interval]))",
                    "legendFormat": "{{failure_reason}}",
                    "range": true,
                    "refId": "A"
                }
            ],
            "title": "Workflow task failures on the queue",
            "type": "timeseries"
        },
        {
            "gridPos": {
                "h": 8,
                "w": 12,
                "x": 12,
                "y": 68
            },
            "id": 53,
            "options": {
                "content": "- **The queue is shared.** Only the two \"Notebook\" panels filter to notebooks. Backlog, wait, sync match, slots, and workflow task failures cover every workload on `general-purpose-task-queue`.\n- **No notebook-only queue wait exists.** The SDK schedule-to-start series has no workflow or activity label. Temporal Cloud has notebook-labeled series, but it emits them only in minutes with events. Its workflow latency for `notebook-sandbox-cmd-run` also includes the result grace sleep.\n- **Where users feel the wait.** Kernel-lane node runs and frame materializations go through this queue, so \"Node run duration\" above includes the wait. The direct lane uses Celery and does not. The materialize histograms further down start at activity start and exclude the wait.\n- **Fleet views:** [Temporal worker health](/d/temporal-worker-health/temporal-worker-health?var-TaskQueue=general-purpose-task-queue) \u00b7 [Temporal Cloud OpenMetrics](/d/temporal-cloud-openmetrics/temporal-cloud-openmetrics)",
                "mode": "markdown"
            },
            "title": "Read before you blame the queue",
            "type": "text"
        },
        {
            "collapsed": false,
            "gridPos": {
                "h": 1,
                "w": 24,
                "x": 0,
                "y": 76
            },
            "id": 54,
            "panels": [],
            "title": "Notebook sandboxes \u2014 Modal (count, lifetime, CPU)",
            "type": "row"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "Notebook kernel sandboxes that Modal reports as running, counted by container. Modal exports these series itself, so they include every sandbox the notebook app starts, whatever code path started it. The value is 0 when no notebook sandbox runs.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "decimals": 0,
                    "min": 0,
                    "unit": "short"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 12,
                "x": 0,
                "y": 77
            },
            "id": 55,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "count(modal_container_running_ratio{app_name=\"posthog-sandbox-notebook\",object_type=\"sandbox\"}) or vector(0)",
                    "instant": false,
                    "legendFormat": "alive",
                    "range": true,
                    "refId": "A"
                }
            ],
            "title": "Notebook sandboxes alive",
            "type": "timeseries"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "Distinct notebook sandboxes that ran at any time in the selected range, including sandboxes that started before the range.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "fixedColor": "text",
                        "mode": "fixed"
                    },
                    "decimals": 0,
                    "unit": "short"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 4,
                "x": 12,
                "y": 77
            },
            "id": 56,
            "options": {
                "colorMode": "none",
                "graphMode": "none",
                "justifyMode": "auto",
                "orientation": "auto",
                "reduceOptions": {
                    "calcs": ["lastNotNull"],
                    "fields": "",
                    "values": false
                },
                "textMode": "auto"
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "count(count_over_time(modal_container_running_ratio{app_name=\"posthog-sandbox-notebook\",object_type=\"sandbox\"}[$__range])) or vector(0)",
                    "instant": true,
                    "legendFormat": "sandboxes",
                    "range": false,
                    "refId": "A"
                }
            ],
            "title": "Sandboxes in time range",
            "type": "stat"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "Hours from the first to the last Modal sample of each sandbox, added up. Modal samples each sandbox once a minute, so each sandbox counts up to a minute short. A sandbox that runs past an edge of the range counts only its part inside the range. Multiply by the hourly price of the sandbox size for a cost estimate, because these series do not carry the size.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "fixedColor": "text",
                        "mode": "fixed"
                    },
                    "decimals": 1,
                    "unit": "none"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 4,
                "x": 16,
                "y": 77
            },
            "id": 57,
            "options": {
                "colorMode": "none",
                "graphMode": "none",
                "justifyMode": "auto",
                "orientation": "auto",
                "reduceOptions": {
                    "calcs": ["lastNotNull"],
                    "fields": "",
                    "values": false
                },
                "textMode": "auto"
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "(sum(lifetime(modal_container_running_ratio{app_name=\"posthog-sandbox-notebook\",object_type=\"sandbox\"}[$__range])) / 3600) or vector(0)",
                    "instant": true,
                    "legendFormat": "sandbox-hours",
                    "range": false,
                    "refId": "A"
                }
            ],
            "title": "Sandbox-hours in time range",
            "type": "stat"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "Median and longest sandbox lifetime in the range. A notebook kernel has a fixed lifetime that use does not extend, 1 hour unless the notebook sets another value. Values near that limit mean the sandboxes ran until the limit, not until the work finished.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "fixedColor": "text",
                        "mode": "fixed"
                    },
                    "decimals": 0,
                    "unit": "m"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 4,
                "x": 20,
                "y": 77
            },
            "id": 58,
            "options": {
                "colorMode": "none",
                "graphMode": "none",
                "justifyMode": "auto",
                "orientation": "auto",
                "reduceOptions": {
                    "calcs": ["lastNotNull"],
                    "fields": "",
                    "values": false
                },
                "textMode": "auto"
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "quantile(0.5, lifetime(modal_container_running_ratio{app_name=\"posthog-sandbox-notebook\",object_type=\"sandbox\"}[$__range])) / 60",
                    "instant": true,
                    "legendFormat": "median",
                    "range": false,
                    "refId": "A"
                },
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "max(lifetime(modal_container_running_ratio{app_name=\"posthog-sandbox-notebook\",object_type=\"sandbox\"}[$__range])) / 60",
                    "instant": true,
                    "legendFormat": "longest",
                    "range": false,
                    "refId": "B"
                }
            ],
            "title": "Sandbox lifetime",
            "type": "stat"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "Modal's CPU utilization ratio across running notebook sandboxes. Values above 1 occur, so the unit is probably cores in use and not a share of the reserved CPU. A line near 0 while sandboxes are alive means that the sandboxes are idle and still cost money.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "decimals": 2,
                    "min": 0,
                    "unit": "none"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 8,
                "x": 0,
                "y": 85
            },
            "id": 59,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "avg(modal_cpu_utilization_ratio{app_name=\"posthog-sandbox-notebook\",object_type=\"sandbox\"})",
                    "instant": false,
                    "legendFormat": "average",
                    "range": true,
                    "refId": "A"
                },
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "max(modal_cpu_utilization_ratio{app_name=\"posthog-sandbox-notebook\",object_type=\"sandbox\"})",
                    "instant": false,
                    "legendFormat": "busiest sandbox",
                    "range": true,
                    "refId": "B"
                }
            ],
            "title": "Sandbox CPU use",
            "type": "timeseries"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "Memory in use per notebook sandbox, as Modal reports it. Compare the busiest sandbox with the provisioned size of the notebook's compute preset to see the headroom.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "min": 0,
                    "unit": "bytes"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 8,
                "x": 8,
                "y": 85
            },
            "id": 60,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "avg(modal_memory_usage_bytes{app_name=\"posthog-sandbox-notebook\",object_type=\"sandbox\"})",
                    "instant": false,
                    "legendFormat": "average",
                    "range": true,
                    "refId": "A"
                },
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "max(modal_memory_usage_bytes{app_name=\"posthog-sandbox-notebook\",object_type=\"sandbox\"})",
                    "instant": false,
                    "legendFormat": "busiest sandbox",
                    "range": true,
                    "refId": "B"
                }
            ],
            "title": "Sandbox memory use",
            "type": "timeseries"
        },
        {
            "gridPos": {
                "h": 8,
                "w": 8,
                "x": 16,
                "y": 85
            },
            "id": 61,
            "options": {
                "content": "- **No team, size, or cost.** The Modal labels name the app and the container, not the PostHog team or the compute preset. For cost, multiply sandbox-hours by the hourly price of the size in `compute_pricing.py`.\n- **Lifetimes are sampled.** Modal is scraped once a minute. A very short sandbox can miss every sample, and each lifetime is up to a minute short.\n- **No start rate.** These panels count sandboxes alive and sandboxes in a range. A start rate needs events from the notebooks code.\n- **One Grafana only.** Modal is scraped here and nowhere else, and the labels do not show which region started a sandbox.",
                "mode": "markdown"
            },
            "title": "What the Modal series cannot show",
            "type": "text"
        },
        {
            "collapsed": false,
            "gridPos": {
                "h": 1,
                "w": 24,
                "x": 0,
                "y": 93
            },
            "id": 20,
            "panels": [],
            "title": "Transport A/B \u2014 worker relay vs ClickHouse writes",
            "type": "row"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "The headline A/B: what a user waits, split by the transport that actually served the run's rows. `delivery` is resolved where the data plane picks a transport, so a fallback lands in the bucket it really used, not the one the flags asked for. `direct` and `none` runs are excluded because no transport choice applies to them.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green"
                            }
                        ]
                    },
                    "unit": "s"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 12,
                "x": 0,
                "y": 94
            },
            "id": 21,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "histogram_quantile(0.95, sum by (le, delivery) (rate(posthog_notebooks_node_run_seconds_bucket{delivery=~\"object_relay|object_ch_writes|inline\"}[$__rate_interval])))",
                    "legendFormat": "p95 {{delivery}}",
                    "range": true,
                    "refId": "A"
                },
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "histogram_quantile(0.50, sum by (le, delivery) (rate(posthog_notebooks_node_run_seconds_bucket{delivery=~\"object_relay|object_ch_writes|inline\"}[$__rate_interval])))",
                    "legendFormat": "p50 {{delivery}}",
                    "range": true,
                    "refId": "B"
                }
            ],
            "title": "End-to-end run duration by transport",
            "type": "timeseries"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "Read this before trusting the latency panel. A flat line on one transport means that arm produced no runs, so its percentiles are stale or empty rather than fast. This is also where a silent fallback shows up: object runs collapsing into `inline` while the flag is on means the deployment gate failed, not that the new path is slow.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green"
                            }
                        ]
                    },
                    "unit": "reqps"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 12,
                "x": 12,
                "y": 94
            },
            "id": 22,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "sum by (delivery) (rate(posthog_notebooks_node_run_seconds_count{delivery=~\"object_relay|object_ch_writes|inline\"}[$__rate_interval]))",
                    "legendFormat": "{{delivery}}",
                    "range": true,
                    "refId": "A"
                }
            ],
            "title": "Runs per transport \u2014 is each arm actually running?",
            "type": "timeseries"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "A transport that returns faster while failing more is not faster. Any outcome other than `done` counts, so a materialization dying at its deadline shows up here as well as in the success-only frame histograms further down.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "min": 0,
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green"
                            }
                        ]
                    },
                    "unit": "percentunit"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 24,
                "x": 0,
                "y": 102
            },
            "id": 23,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "sum by (delivery) (rate(posthog_notebooks_node_run_seconds_count{delivery=~\"object_relay|object_ch_writes|inline\",outcome!=\"done\"}[$__rate_interval])) / clamp_min(sum by (delivery) (rate(posthog_notebooks_node_run_seconds_count{delivery=~\"object_relay|object_ch_writes|inline\"}[$__rate_interval])), 1e-9)",
                    "legendFormat": "{{delivery}}",
                    "range": true,
                    "refId": "A"
                }
            ],
            "title": "Failure ratio by transport",
            "type": "timeseries"
        },
        {
            "collapsed": false,
            "gridPos": {
                "h": 1,
                "w": 24,
                "x": 0,
                "y": 110
            },
            "id": 24,
            "panels": [],
            "title": "Rollout state \u2014 is the new path actually engaged?",
            "type": "row"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "Materialize activity attempts started. The started counter carries no labels today \u2014 a mode label (streaming vs CH writes) requires a code change before this can split by delivery path.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green"
                            }
                        ]
                    },
                    "unit": "reqps"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 8,
                "x": 0,
                "y": 111
            },
            "id": 25,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "sum(rate(posthog_notebooks_frame_materializations_started_total[$__rate_interval]))",
                    "legendFormat": "started",
                    "range": true,
                    "refId": "A"
                }
            ],
            "title": "Materialize attempts",
            "type": "timeseries"
        },
        {
            "gridPos": {
                "h": 8,
                "w": 8,
                "x": 8,
                "y": 111
            },
            "id": 26,
            "options": {
                "content": "No Prometheus metric carries the ClickHouse identity \u2014 the dedicated `notebooks` CH user and offline-pool prerequisites fail open and silently.\n\nVerify them ClickHouse-side with **query 2** of `observability/notebooks-query-log.sql` (Metabase): `user` should be `notebooks` and `lc_workload` should be `offline` once provisioned.",
                "mode": "markdown"
            },
            "title": "Prerequisite check \u2014 CH user and pool routing",
            "type": "text"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "An object-delivery request served over the Redis transport instead, silently clamped at 50k rows. Non-zero means the frame store is disabled or object storage is unconfigured, and users may be getting truncated frames with no signal. Should be flat zero once the flag is on.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "custom": {
                        "fillOpacity": 20
                    },
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green"
                            },
                            {
                                "color": "red",
                                "value": 0.001
                            }
                        ]
                    },
                    "unit": "reqps"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 8,
                "x": 16,
                "y": 111
            },
            "id": 27,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "sum(rate(posthog_notebooks_frame_store_fallback_inline_total[$__rate_interval]))",
                    "legendFormat": "fallback to inline",
                    "range": true,
                    "refId": "A"
                }
            ],
            "title": "Degraded mode \u2014 object delivery falling back to inline",
            "type": "timeseries"
        },
        {
            "collapsed": false,
            "gridPos": {
                "h": 1,
                "w": 24,
                "x": 0,
                "y": 119
            },
            "id": 28,
            "panels": [],
            "title": "Outcomes",
            "type": "row"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "Materialize jobs reaching a terminal state, by outcome. The finished counter has no mode label \u2014 path-specific failure rates need a code change first.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green"
                            }
                        ]
                    },
                    "unit": "reqps"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 8,
                "x": 0,
                "y": 120
            },
            "id": 29,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "sum by (outcome) (rate(posthog_notebooks_frame_materializations_finished_total[$__rate_interval]))",
                    "legendFormat": "{{outcome}}",
                    "range": true,
                    "refId": "A"
                }
            ],
            "title": "Terminal outcomes",
            "type": "timeseries"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "Share of materialize jobs reaching a terminal failed state. Counts jobs, not attempts.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green"
                            },
                            {
                                "color": "yellow",
                                "value": 0.02
                            },
                            {
                                "color": "red",
                                "value": 0.1
                            }
                        ]
                    },
                    "unit": "percentunit"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 4,
                "x": 8,
                "y": 120
            },
            "id": 30,
            "options": {
                "colorMode": "value",
                "graphMode": "area",
                "justifyMode": "auto",
                "orientation": "auto",
                "reduceOptions": {
                    "calcs": ["lastNotNull"],
                    "fields": "",
                    "values": false
                },
                "textMode": "auto"
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "sum(rate(posthog_notebooks_frame_materializations_finished_total{outcome=\"failed\"}[$__rate_interval])) / clamp_min(sum(rate(posthog_notebooks_frame_materializations_finished_total[$__rate_interval])), 0.0000001)",
                    "legendFormat": "failed",
                    "range": true,
                    "refId": "A"
                }
            ],
            "title": "Failure ratio",
            "type": "stat"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "started counts attempts; finished counts jobs. 1.0 means every job succeeds first try. Sustained >2 means jobs are bouncing off the concurrency limiter or hitting retryable ClickHouse errors, and each retry re-executes the scan.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "decimals": 2,
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green"
                            },
                            {
                                "color": "yellow",
                                "value": 2
                            },
                            {
                                "color": "red",
                                "value": 4
                            }
                        ]
                    },
                    "unit": "none"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 4,
                "x": 12,
                "y": 120
            },
            "id": 31,
            "options": {
                "colorMode": "value",
                "graphMode": "area",
                "justifyMode": "auto",
                "orientation": "auto",
                "reduceOptions": {
                    "calcs": ["lastNotNull"],
                    "fields": "",
                    "values": false
                },
                "textMode": "auto"
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "sum(rate(posthog_notebooks_frame_materializations_started_total[$__rate_interval])) / clamp_min(sum(rate(posthog_notebooks_frame_materializations_finished_total[$__rate_interval])), 0.0000001)",
                    "legendFormat": "attempts/job",
                    "range": true,
                    "refId": "A"
                }
            ],
            "title": "Retry amplification (attempts per job)",
            "type": "stat"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "Identical in-flight materializations (same team + user + query) joining a running job instead of stacking ClickHouse load. Healthy \u2014 this is load the cluster never saw.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green"
                            }
                        ]
                    },
                    "unit": "reqps"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 8,
                "x": 16,
                "y": 120
            },
            "id": 32,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "sum(rate(posthog_notebooks_frame_materializations_deduplicated_total[$__rate_interval]))",
                    "legendFormat": "deduplicated",
                    "range": true,
                    "refId": "A"
                }
            ],
            "title": "Deduplicated requests",
            "type": "timeseries"
        },
        {
            "collapsed": false,
            "gridPos": {
                "h": 1,
                "w": 24,
                "x": 0,
                "y": 128
            },
            "id": 33,
            "panels": [],
            "title": "Latency \u2014 WARNING: success-only, see dashboard description",
            "type": "row"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "SUCCESS ONLY, and the clock starts at ACTIVITY START \u2014 enqueue, Temporal scheduling, task-queue wait and retry backoff are all excluded. A job that times out at 10 minutes contributes no sample at all. Treat as a floor on user-perceived latency, not as E2E.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green"
                            }
                        ]
                    },
                    "unit": "s"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 12,
                "x": 0,
                "y": 129
            },
            "id": 34,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "histogram_quantile(0.50, sum by (le) (rate(posthog_notebooks_frame_materialize_seconds_bucket[$__rate_interval])))",
                    "legendFormat": "p50",
                    "range": true,
                    "refId": "A"
                },
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "histogram_quantile(0.95, sum by (le) (rate(posthog_notebooks_frame_materialize_seconds_bucket[$__rate_interval])))",
                    "legendFormat": "p95",
                    "range": true,
                    "refId": "B"
                },
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "histogram_quantile(0.99, sum by (le) (rate(posthog_notebooks_frame_materialize_seconds_bucket[$__rate_interval])))",
                    "legendFormat": "p99",
                    "range": true,
                    "refId": "C"
                }
            ],
            "title": "Materialize duration (activity start to object stored)",
            "type": "timeseries"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "Time a successful materialize spent blocked on ClickHouse: response headers plus blocking body reads of the streaming relay. Success-only (see dashboard description).",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green"
                            }
                        ]
                    },
                    "unit": "s"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 12,
                "x": 12,
                "y": 129
            },
            "id": 35,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "histogram_quantile(0.95, sum by (le) (rate(posthog_notebooks_frame_clickhouse_seconds_bucket[$__rate_interval])))",
                    "legendFormat": "p95",
                    "range": true,
                    "refId": "A"
                }
            ],
            "title": "ClickHouse time p95",
            "type": "timeseries"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "Mean seconds per successful materialize spent on each side of the worker relay. If the upload half starts dominating p95, that is the trigger for flipping NOTEBOOKS_FRAME_STORE_CH_WRITES on. No upload series is emitted on the ch_writes path \u2014 ClickHouse does the upload there.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green"
                            }
                        ]
                    },
                    "unit": "s"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 12,
                "x": 0,
                "y": 137
            },
            "id": 36,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "sum(rate(posthog_notebooks_frame_clickhouse_seconds_sum[$__rate_interval])) / clamp_min(sum(rate(posthog_notebooks_frame_clickhouse_seconds_count[$__rate_interval])), 0.0000001)",
                    "legendFormat": "clickhouse (mean)",
                    "range": true,
                    "refId": "A"
                },
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "sum(rate(posthog_notebooks_frame_upload_seconds_sum[$__rate_interval])) / clamp_min(sum(rate(posthog_notebooks_frame_upload_seconds_count[$__rate_interval])), 0.0000001)",
                    "legendFormat": "object store upload (mean)",
                    "range": true,
                    "refId": "B"
                }
            ],
            "title": "Relay split \u2014 where is the worker blocked? (streaming only)",
            "type": "timeseries"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "Stored object bytes. The 2GB result cap (_MAX_RESULT_BYTES) is enforced in-flight on the streaming path but only POST-WRITE on the ch_writes path \u2014 on ch_writes a pathological wide-row query can write tens of GB before the size check deletes it. Watch the top bucket after flipping that flag.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green"
                            }
                        ]
                    },
                    "unit": "bytes"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 12,
                "x": 12,
                "y": 137
            },
            "id": 37,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "histogram_quantile(0.50, sum by (le) (rate(posthog_notebooks_frame_object_bytes_bucket[$__rate_interval])))",
                    "legendFormat": "p50",
                    "range": true,
                    "refId": "A"
                },
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "histogram_quantile(0.95, sum by (le) (rate(posthog_notebooks_frame_object_bytes_bucket[$__rate_interval])))",
                    "legendFormat": "p95",
                    "range": true,
                    "refId": "B"
                },
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "histogram_quantile(0.99, sum by (le) (rate(posthog_notebooks_frame_object_bytes_bucket[$__rate_interval])))",
                    "legendFormat": "p99",
                    "range": true,
                    "refId": "C"
                }
            ],
            "title": "Frame object size",
            "type": "timeseries"
        },
        {
            "collapsed": false,
            "gridPos": {
                "h": 1,
                "w": 24,
                "x": 0,
                "y": 145
            },
            "id": 38,
            "panels": [],
            "title": "Throttling and concurrency",
            "type": "row"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "Rejections against the Redis-Lua slots (global 10, per-team 2). A rejection is retryable \u2014 Temporal backs off \u2014 so a moderate rate is the limiter working, not an outage. Sustained per-team blocks with a low global rate means one team is self-limiting; a high global rate means the fleet ceiling is the binding constraint. NOTE: notebooks' limiters do not set RateLimit.retry, so rejections land as result=block and never result=retry.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green"
                            }
                        ]
                    },
                    "unit": "reqps"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 12,
                "x": 0,
                "y": 146
            },
            "id": 39,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "sum by (limit_name, result) (rate(posthog_clickhouse_query_concurrency_limit_exceeded_total{limit_name=~\"notebooks_materialize_.*\"}[$__rate_interval]))",
                    "legendFormat": "{{limit_name}} / {{result}}",
                    "range": true,
                    "refId": "A"
                }
            ],
            "title": "Concurrency slot rejections",
            "type": "timeseries"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "Teams whose materializations are being blocked. Identifies who to talk to before raising MATERIALIZE_PER_TEAM_CONCURRENCY. For actual slot occupancy (which nothing exports today) reconstruct it from query_log_archive \u2014 see notebooks-query-log.sql query 5.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green"
                            }
                        ]
                    },
                    "unit": "reqps"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 12,
                "x": 12,
                "y": 146
            },
            "id": 40,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "topk(10, sum by (team_id) (rate(posthog_clickhouse_query_concurrency_limit_exceeded_total{limit_name=~\"notebooks_materialize_.*\", result=\"block\"}[$__rate_interval])))",
                    "legendFormat": "team {{team_id}}",
                    "range": true,
                    "refId": "A"
                }
            ],
            "title": "Top teams hitting the per-team ceiling",
            "type": "timeseries"
        },
        {
            "collapsed": false,
            "gridPos": {
                "h": 1,
                "w": 24,
                "x": 0,
                "y": 154
            },
            "id": 41,
            "panels": [],
            "title": "HTTP surface",
            "type": "row"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "Per-REQUEST latency of the sandbox's POST /internal/notebooks/data_plane/query/ and its status polls. This is NOT query latency \u2014 the POST returns 202 as soon as the job is enqueued and each poll returns 202 or a 302 immediately. It answers 'is the data plane responsive', not 'how long do users wait'. The view label value is unverified: these paths have no name= in urls.py, so confirm it with list_prometheus_label_values before trusting this panel.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green"
                            }
                        ]
                    },
                    "unit": "s"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 12,
                "x": 0,
                "y": 155
            },
            "id": 42,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "histogram_quantile(0.95, sum by (le, view) (rate(django_http_requests_latency_seconds_by_view_method_bucket{view=~\".*notebook.*data_plane.*\"}[$__rate_interval])))",
                    "legendFormat": "p95 {{view}}",
                    "range": true,
                    "refId": "A"
                }
            ],
            "title": "Data-plane endpoint latency p95",
            "type": "timeseries"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "description": "The user-facing REST surface (api/projects/:id/notebooks/...), including the sql_v2_run dispatch action. posthog_api_requests_latency_seconds only covers paths containing 'api/', which is why the internal data-plane endpoints are on the panel to the left instead.",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green"
                            }
                        ]
                    },
                    "unit": "s"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 12,
                "x": 12,
                "y": 155
            },
            "id": 43,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "histogram_quantile(0.95, sum by (le, view) (rate(posthog_api_requests_latency_seconds_bucket{view=~\".*notebook.*\"}[$__rate_interval])))",
                    "legendFormat": "p95 {{view}}",
                    "range": true,
                    "refId": "A"
                }
            ],
            "title": "Notebooks API latency p95 by view",
            "type": "timeseries"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
            },
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green"
                            }
                        ]
                    },
                    "unit": "reqps"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 24,
                "x": 0,
                "y": 163
            },
            "id": 44,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${datasource}"
                    },
                    "editorMode": "code",
                    "expr": "sum by (view, status_class) (rate(posthog_api_requests_latency_seconds_count{view=~\".*notebook.*\"}[$__rate_interval]))",
                    "legendFormat": "{{view}} {{status_class}}",
                    "range": true,
                    "refId": "A"
                }
            ],
            "title": "Notebooks API responses by status class",
            "type": "timeseries"
        }
    ],
    "refresh": "1m",
    "schemaVersion": 42,
    "tags": ["notebooks", "sqlv2", "frame-store", "mcp"],
    "templating": {
        "list": [
            {
                "current": {
                    "selected": false,
                    "text": "victoriametrics",
                    "value": "victoriametrics"
                },
                "hide": 0,
                "includeAll": false,
                "label": "Datasource",
                "multi": false,
                "name": "datasource",
                "options": [],
                "query": "prometheus",
                "queryValue": "",
                "refresh": 1,
                "regex": "",
                "skipUrlSync": false,
                "type": "datasource"
            }
        ]
    },
    "time": {
        "from": "now-6h",
        "to": "now"
    },
    "timepicker": {},
    "timezone": "utc",
    "title": "Notebooks \u2014 rollout and errors",
    "uid": "notebooks-sqlv2-rollout",
    "weekStart": ""
}