{
  "uid": "scrabble-bot",
  "title": "Scrabble — Telegram bot",
  "tags": ["scrabble"],
  "timezone": "",
  "schemaVersion": 39,
  "version": 1,
  "refresh": "30s",
  "time": { "from": "now-6h", "to": "now" },
  "panels": [
    {
      "type": "stat",
      "title": "Bot connected",
      "description": "botlink_connected_bots: bots currently holding the gateway bot-link (1 = healthy).",
      "gridPos": { "h": 5, "w": 6, "x": 0, "y": 0 },
      "datasource": { "type": "prometheus", "uid": "prometheus" },
      "targets": [{ "refId": "A", "expr": "max(botlink_connected_bots)" }]
    },
    {
      "type": "stat",
      "title": "Last Bot API OK (age)",
      "description": "Seconds since the bot's most recent successful Bot API call. Grows unbounded if the bot wedges.",
      "gridPos": { "h": 5, "w": 6, "x": 6, "y": 0 },
      "fieldConfig": { "defaults": { "unit": "s" }, "overrides": [] },
      "datasource": { "type": "prometheus", "uid": "prometheus" },
      "targets": [{ "refId": "A", "expr": "time() - max(bot_tg_last_ok_unix)" }]
    },
    {
      "type": "timeseries",
      "title": "Bot API errors/s by kind",
      "description": "bot_tg_errors_total by kind: connect (getUpdates), api (other sends), rate_limited (429). 429 should stay ~0.",
      "gridPos": { "h": 8, "w": 12, "x": 12, "y": 0 },
      "datasource": { "type": "prometheus", "uid": "prometheus" },
      "targets": [{ "refId": "A", "expr": "sum by (kind) (rate(bot_tg_errors_total[5m]))", "legendFormat": "{{kind}}" }]
    },
    {
      "type": "timeseries",
      "title": "Bot-link commands/s by result",
      "description": "botlink_commands_total by result: delivered / not_delivered / dropped / error. Sustained not_delivered or error means gateway sends are failing to reach Telegram.",
      "gridPos": { "h": 8, "w": 12, "x": 0, "y": 5 },
      "datasource": { "type": "prometheus", "uid": "prometheus" },
      "targets": [{ "refId": "A", "expr": "sum by (result) (rate(botlink_commands_total[5m]))", "legendFormat": "{{result}}" }]
    }
  ]
}
