{
  "title": "Пайплайны пост-обработки",
  "description": "Требует профилей compose transcribe/llm (см. .env.example, COMPOSE_PROFILES) — по умолчанию (media,monitoring) большинство панелей будет показывать «No data», это ожидаемо, не баг.",
  "uid": "vidconf-pipelines",
  "editable": false,
  "timezone": "browser",
  "schemaVersion": 39,
  "version": 1,
  "time": { "from": "now-6h", "to": "now" },
  "refresh": "30s",
  "tags": ["vidconf", "pipeline"],
  "panels": [
    {
      "id": 1,
      "title": "Сеансы по статусу пайплайна",
      "description": "conference_sessions.pipeline_status (recording→transcribing→summarizing→notified|failed), метрика vidconf_pipeline_sessions.",
      "type": "timeseries",
      "gridPos": { "h": 8, "w": 12, "x": 0, "y": 0 },
      "datasource": { "type": "prometheus", "uid": "prometheus" },
      "fieldConfig": {
        "defaults": { "custom": { "drawStyle": "line", "fillOpacity": 10, "stacking": { "mode": "normal" } } },
        "overrides": []
      },
      "targets": [
        {
          "datasource": { "type": "prometheus", "uid": "prometheus" },
          "expr": "vidconf_pipeline_sessions",
          "legendFormat": "{{status}}",
          "refId": "A"
        }
      ]
    },
    {
      "id": 2,
      "title": "Глубина очередей Celery",
      "description": "vidconf_celery_queue_depth{queue=...} — transcription/summarize/notify/celery (redis LLEN). Порог алерта QueueGrowing см. deploy/monitoring/alerts.yml.",
      "type": "timeseries",
      "gridPos": { "h": 8, "w": 12, "x": 12, "y": 0 },
      "datasource": { "type": "prometheus", "uid": "prometheus" },
      "fieldConfig": {
        "defaults": { "custom": { "drawStyle": "line", "fillOpacity": 10 } },
        "overrides": []
      },
      "targets": [
        {
          "datasource": { "type": "prometheus", "uid": "prometheus" },
          "expr": "vidconf_celery_queue_depth",
          "legendFormat": "{{queue}}",
          "refId": "A"
        }
      ]
    },
    {
      "id": 3,
      "title": "Латентность API (p50/p95/p99 по маршрутам)",
      "description": "vidconf_http_request_duration_seconds — histogram латентности HTTP по шаблону маршрута.",
      "type": "timeseries",
      "gridPos": { "h": 8, "w": 12, "x": 0, "y": 8 },
      "datasource": { "type": "prometheus", "uid": "prometheus" },
      "fieldConfig": {
        "defaults": { "unit": "s", "custom": { "drawStyle": "line", "fillOpacity": 5 } },
        "overrides": []
      },
      "targets": [
        {
          "datasource": { "type": "prometheus", "uid": "prometheus" },
          "expr": "histogram_quantile(0.50, sum(rate(vidconf_http_request_duration_seconds_bucket[5m])) by (le, path))",
          "legendFormat": "p50 {{path}}",
          "refId": "A"
        },
        {
          "datasource": { "type": "prometheus", "uid": "prometheus" },
          "expr": "histogram_quantile(0.95, sum(rate(vidconf_http_request_duration_seconds_bucket[5m])) by (le, path))",
          "legendFormat": "p95 {{path}}",
          "refId": "B"
        },
        {
          "datasource": { "type": "prometheus", "uid": "prometheus" },
          "expr": "histogram_quantile(0.99, sum(rate(vidconf_http_request_duration_seconds_bucket[5m])) by (le, path))",
          "legendFormat": "p99 {{path}}",
          "refId": "C"
        }
      ]
    },
    {
      "id": 4,
      "title": "Длительность шагов пайплайна (p95)",
      "description": "Ожидает метрику vidconf_pipeline_step_duration_seconds (histogram, label step) — пока не реализована (backend/api/metrics.py содержит только латентность HTTP и gauge'и статусов/очередей). Панель — заготовка под будущую инструментацию шагов transcribing/summarizing/notified; до её появления показывает «No data».",
      "type": "timeseries",
      "gridPos": { "h": 8, "w": 12, "x": 12, "y": 8 },
      "datasource": { "type": "prometheus", "uid": "prometheus" },
      "fieldConfig": {
        "defaults": { "unit": "s", "custom": { "drawStyle": "line", "fillOpacity": 5 } },
        "overrides": []
      },
      "targets": [
        {
          "datasource": { "type": "prometheus", "uid": "prometheus" },
          "expr": "histogram_quantile(0.95, sum(rate(vidconf_pipeline_step_duration_seconds_bucket[15m])) by (le, step))",
          "legendFormat": "p95 {{step}}",
          "refId": "A"
        }
      ]
    },
    {
      "id": 5,
      "title": "LLM-сервер доступен (job=llm)",
      "description": "up{job=\"llm\"} — 1, если Prometheus успешно скрейпит llama.cpp (алерт LlmDown, deploy/monitoring/alerts.yml). Job llm и алерт LlmDown закомментированы по умолчанию (см. prometheus.yml/alerts.yml) — раскомментируйте оба на инсталляциях с профилем llm/llm-gpu (пресеты 3–5), иначе эта панель показывает «No data».",
      "type": "stat",
      "gridPos": { "h": 4, "w": 6, "x": 0, "y": 16 },
      "datasource": { "type": "prometheus", "uid": "prometheus" },
      "fieldConfig": {
        "defaults": {
          "mappings": [
            { "type": "value", "options": { "0": { "text": "DOWN", "color": "red" }, "1": { "text": "UP", "color": "green" } } }
          ],
          "thresholds": { "mode": "absolute", "steps": [{ "color": "red", "value": null }, { "color": "green", "value": 1 }] }
        },
        "overrides": []
      },
      "targets": [
        {
          "datasource": { "type": "prometheus", "uid": "prometheus" },
          "expr": "up{job=\"llm\"}",
          "refId": "A"
        }
      ]
    },
    {
      "id": 6,
      "title": "Сеансы failed (текущее число)",
      "description": "vidconf_pipeline_sessions{status=\"failed\"} — алерт PipelineFailed срабатывает на росте за 15 минут, здесь — снимок текущего значения.",
      "type": "stat",
      "gridPos": { "h": 4, "w": 6, "x": 6, "y": 16 },
      "datasource": { "type": "prometheus", "uid": "prometheus" },
      "fieldConfig": {
        "defaults": {
          "thresholds": { "mode": "absolute", "steps": [{ "color": "green", "value": null }, { "color": "red", "value": 1 }] }
        },
        "overrides": []
      },
      "targets": [
        {
          "datasource": { "type": "prometheus", "uid": "prometheus" },
          "expr": "vidconf_pipeline_sessions{status=\"failed\"}",
          "refId": "A"
        }
      ]
    }
  ]
}
