{
  "_doc": [
    "DraftForge Loki datasource — source of truth for derived fields.",
    "",
    "Apply with `docs/dev/telemetry/datasources/apply.sh` (uses gcx auth context).",
    "",
    "Portability: this file targets Grafana Cloud HTTP API. For a self-hosted",
    "Grafana (e.g. eventual home-cluster move), copy the `jsonData.derivedFields`",
    "block into `provisioning/datasources/loki.yaml` under `datasources[].jsonData.",
    "derivedFields`. The schema is identical; only the wrapper format differs.",
    "",
    "Secrets (basicAuthPassword) are NOT in this file. They stay configured",
    "server-side via the Grafana UI once; subsequent PUTs preserve them as",
    "long as `secureJsonData` is omitted from the body."
  ],
  "uid": "grafanacloud-logs",
  "name": "grafanacloud-kettle-logs",
  "type": "loki",
  "access": "proxy",
  "url": "https://logs-prod-042.grafana.net",
  "basicAuth": true,
  "basicAuthUser": "1458154",
  "isDefault": false,
  "jsonData": {
    "timeout": "300",
    "streamingEnabled": {
      "search": true
    },
    "derivedFields": [
      {
        "_doc": "Click any traceID in a log line -> open the trace in Tempo.",
        "name": "traceID",
        "matcherType": "regex",
        "matcherRegex": "[tT]race_?[iI][dD]\"?[:=]\"?(\\w+)",
        "datasourceUid": "grafanacloud-traces",
        "url": "${__value.raw}"
      },
      {
        "_doc": "Same as above, but pulled from the `traceID` OTel attribute label instead of regex on the body.",
        "name": "traceID (field)",
        "matcherType": "label",
        "matcherRegex": "[tT]race_?[iI][dD]",
        "datasourceUid": "grafanacloud-traces",
        "url": "${__value.raw}"
      },
      {
        "_doc": "Extract ws_conn_id from log lines. No internal link — Grafana restricts 'Internal link' to cross-datasource targets (logs↔traces). Same-datasource filtering happens via the +/- chips in the expanded log row.",
        "name": "wsConnId",
        "matcherType": "regex",
        "matcherRegex": "\"?ws[._]conn_id\"?\\s*[:=]\\s*\"?([a-f0-9-]+)"
      },
      {
        "_doc": "Extract user_id from log lines. Same UX as wsConnId — expand a row and click + on the chip to filter the query.",
        "name": "userId",
        "matcherType": "regex",
        "matcherRegex": "\"?user_id\"?\\s*[:=]\\s*\"?(\\d+)"
      },
      {
        "_doc": "Extract draft_id from log lines. Same UX as wsConnId — expand a row and click + on the chip to filter the query.",
        "name": "draftId",
        "matcherType": "regex",
        "matcherRegex": "\"?draft_id\"?\\s*[:=]\\s*\"?(\\d+)"
      }
    ]
  }
}
