{
  "schemes": ["http", "https"],
  "swagger": "2.0",
  "info": {
    "description": "API for TiDB Cloud Observability diagnosis: TopSQL, TopRU, Slow Query, Key Visualizer, Statements, Continuous Profiling. For AI and human developers.",
    "title": "Diagnosis Query API",
    "contact": {},
    "license": {
      "name": "Apache-2.0",
      "url": "https://www.apache.org/licenses/LICENSE-2.0.html"
    },
    "version": "1.0"
  },
  "host": "localhost:8081",
  "basePath": "/api/v1",
  "paths": {
    "/continuous_profiling/action_token": {
      "get": {
        "description": "Generate a signed token used by the download and single-view endpoints to authorize profiling file generation.",
        "produces": ["application/json"],
        "tags": ["conprof"],
        "summary": "Create a token for profile download/view",
        "parameters": [
          {
            "type": "string",
            "description": "Cloud provider where profiling data is stored: aws or gcp",
            "name": "x-provider",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Cloud region where the profiling bucket is deployed",
            "name": "x-region",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Organization ID in TiDB Cloud (if applicable)",
            "name": "x-org-id",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Project ID in TiDB Cloud (if applicable)",
            "name": "x-project-id",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Observability cluster ID for the target TiDB deployment",
            "name": "x-cluster-id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Raw query string for the target profile, e.g. ts=...\u0026address=...\u0026component=...\u0026profile_type=...",
            "name": "q",
            "in": "query",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "type": "string"
            }
          }
        }
      }
    },
    "/continuous_profiling/download": {
      "get": {
        "description": "Download the requested profiling data as a ZIP file (including a README) for offline analysis.",
        "tags": ["conprof"],
        "summary": "Download the selected profile as a ZIP",
        "parameters": [
          {
            "type": "string",
            "description": "Signed token generated by /continuous_profiling/action_token",
            "name": "token",
            "in": "query",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "type": "file"
            }
          }
        }
      }
    },
    "/continuous_profiling/group_profile/detail": {
      "get": {
        "description": "Fetch the target profiles inside a continuous profiling group at the given timestamp.",
        "produces": ["application/json"],
        "tags": ["conprof"],
        "summary": "Get details for a specific profiling group",
        "parameters": [
          {
            "type": "string",
            "description": "Cloud provider where profiling data is stored: aws or gcp",
            "name": "x-provider",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Cloud region where the profiling bucket is deployed",
            "name": "x-region",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Organization ID in TiDB Cloud (if applicable)",
            "name": "x-org-id",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Project ID in TiDB Cloud (if applicable)",
            "name": "x-project-id",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Observability cluster ID for the target TiDB deployment",
            "name": "x-cluster-id",
            "in": "header",
            "required": true
          },
          {
            "type": "integer",
            "description": "Unix timestamp in seconds identifying the profiling group",
            "name": "ts",
            "in": "query",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/conprof.detailResponse"
            }
          }
        }
      }
    },
    "/continuous_profiling/group_profiles": {
      "get": {
        "description": "List continuous profiling group profiles for a given cluster and time window.",
        "produces": ["application/json"],
        "tags": ["conprof"],
        "summary": "List available continuous profiling groups",
        "parameters": [
          {
            "type": "string",
            "description": "Cloud provider where profiling data is stored: aws or gcp",
            "name": "x-provider",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Cloud region where the profiling bucket is deployed",
            "name": "x-region",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Organization ID in TiDB Cloud (if applicable)",
            "name": "x-org-id",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Project ID in TiDB Cloud (if applicable)",
            "name": "x-project-id",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Observability cluster ID for the target TiDB deployment",
            "name": "x-cluster-id",
            "in": "header",
            "required": true
          },
          {
            "type": "integer",
            "description": "Start time (Unix seconds, inclusive)",
            "name": "begin_time",
            "in": "query",
            "required": true
          },
          {
            "type": "integer",
            "description": "End time (Unix seconds, inclusive)",
            "name": "end_time",
            "in": "query",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/conprof.listResponseItem"
              }
            }
          }
        }
      }
    },
    "/continuous_profiling/single_profile/view": {
      "get": {
        "description": "Generate a single-profile view artifact that can be consumed by speedscope.",
        "tags": ["conprof"],
        "summary": "View the selected profile in speedscope",
        "parameters": [
          {
            "type": "string",
            "description": "Signed token generated by /continuous_profiling/action_token",
            "name": "token",
            "in": "query",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "type": "file"
            }
          }
        }
      }
    },
    "/keyvisual/config": {
      "get": {
        "description": "Return Key Visual (TiKV key heatmaps) configuration for diagnosis pages.",
        "summary": "Get Key Visual configuration",
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/keyviz.KeyVisualConfig"
            }
          }
        }
      }
    },
    "/keyvisual/heatmaps": {
      "get": {
        "description": "Return TiKV usage heatmaps for a key range and time window. The `type` controls what signal is visualized.",
        "summary": "Get Key Visual heatmaps",
        "parameters": [
          {
            "type": "string",
            "description": "Cloud provider where key visualization data is stored (aws or gcp)",
            "name": "x-provider",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Cloud region where key visualization data is stored",
            "name": "x-region",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Organization ID (x-org-id)",
            "name": "x-org-id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Project ID (x-project-id)",
            "name": "x-project-id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Cluster ID (x-cluster-id)",
            "name": "x-cluster-id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Deployment tier (dedicated/shared)",
            "name": "x-deploy-type",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Environment (e.g. prod)",
            "name": "x-env",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Start key (inclusive) for the key range",
            "name": "startkey",
            "in": "query"
          },
          {
            "type": "string",
            "description": "End key (exclusive) for the key range",
            "name": "endkey",
            "in": "query"
          },
          {
            "type": "integer",
            "description": "Start time (Unix seconds) for the time range",
            "name": "starttime",
            "in": "query"
          },
          {
            "type": "integer",
            "description": "End time (Unix seconds) for the time range",
            "name": "endtime",
            "in": "query"
          },
          {
            "enum": ["written_bytes", "read_bytes", "written_keys", "read_keys", "integration"],
            "type": "string",
            "description": "Heatmap signal type",
            "name": "type",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/k.Matrix"
            }
          }
        }
      }
    },
    "/slow_query/available_fields": {
      "get": {
        "description": "List the available slow query fields that can be requested via the `fields` parameter of `/slow_query/list`. Fields are filtered by the cluster's slowlog table schema.",
        "produces": ["application/json"],
        "tags": ["slowquery"],
        "summary": "List selectable fields for slow query",
        "parameters": [
          {
            "type": "string",
            "description": "Cloud provider for the query: aws or gcp",
            "name": "x-provider",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Cloud region where slow logs are stored",
            "name": "x-region",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Organization ID in TiDB Cloud (if applicable)",
            "name": "x-org-id",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Project ID in TiDB Cloud (if applicable)",
            "name": "x-project-id",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Observability cluster ID for the target TiDB deployment",
            "name": "x-cluster-id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Deployment type: dedicated/shared/nextgen/premium",
            "name": "x-deploy-type",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Environment, default prod",
            "name": "x-env",
            "in": "header"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        }
      }
    },
    "/slow_query/databases": {
      "get": {
        "description": "Return the database names that have slow queries within a given time window.",
        "produces": ["application/json"],
        "tags": ["slowquery"],
        "summary": "List databases with slow queries",
        "parameters": [
          {
            "type": "string",
            "description": "Cloud provider for the query: aws or gcp",
            "name": "x-provider",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Cloud region where slow logs are stored",
            "name": "x-region",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Organization ID in TiDB Cloud (if applicable)",
            "name": "x-org-id",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Project ID in TiDB Cloud (if applicable)",
            "name": "x-project-id",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Observability cluster ID for the target TiDB deployment",
            "name": "x-cluster-id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Deployment tier: dedicated/shared/nextgen/premium",
            "name": "x-deploy-type",
            "in": "header"
          },
          {
            "type": "integer",
            "description": "Start time (Unix seconds, inclusive)",
            "name": "begin_time",
            "in": "query",
            "required": true
          },
          {
            "type": "integer",
            "description": "End time (Unix seconds, inclusive)",
            "name": "end_time",
            "in": "query",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        }
      }
    },
    "/slow_query/detail": {
      "get": {
        "description": "Fetch the matched slow query record detail identified by digest, timestamp, and connection ID.",
        "produces": ["application/json"],
        "tags": ["slowquery"],
        "summary": "Get slow query detail",
        "parameters": [
          {
            "type": "string",
            "description": "Cloud provider for the query: aws or gcp",
            "name": "x-provider",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Cloud region where slow logs are stored",
            "name": "x-region",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Organization ID in TiDB Cloud (if applicable)",
            "name": "x-org-id",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Project ID in TiDB Cloud (if applicable)",
            "name": "x-project-id",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Observability cluster ID for the target TiDB deployment",
            "name": "x-cluster-id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Deployment tier: dedicated/shared/nextgen/premium",
            "name": "x-deploy-type",
            "in": "header"
          },
          {
            "type": "string",
            "description": "SQL digest (fingerprint) to match slow log item",
            "name": "digest",
            "in": "query",
            "required": true
          },
          {
            "type": "number",
            "description": "Unix timestamp in seconds to match slow log item",
            "name": "timestamp",
            "in": "query",
            "required": true
          },
          {
            "type": "string",
            "description": "Connection ID to match slow log item",
            "name": "connect_id",
            "in": "query",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/slowquery.slowLogRespItem"
            }
          }
        }
      }
    },
    "/slow_query/list": {
      "get": {
        "description": "Query slow query logs for a cluster within a time range, with optional filtering (digest, databases, fields).",
        "produces": ["application/json"],
        "tags": ["slowquery"],
        "summary": "List slow queries",
        "parameters": [
          {
            "type": "string",
            "description": "Cloud provider for the query: aws or gcp",
            "name": "x-provider",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Cloud region where slow logs are stored",
            "name": "x-region",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Organization ID in TiDB Cloud (if applicable)",
            "name": "x-org-id",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Project ID in TiDB Cloud (if applicable)",
            "name": "x-project-id",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Observability cluster ID for the target TiDB deployment",
            "name": "x-cluster-id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Deployment tier: dedicated/shared/nextgen/premium",
            "name": "x-deploy-type",
            "in": "header"
          },
          {
            "type": "integer",
            "description": "Optional start time (Unix seconds, inclusive)",
            "name": "begin_time",
            "in": "query"
          },
          {
            "type": "integer",
            "description": "End time (Unix seconds, inclusive)",
            "name": "end_time",
            "in": "query",
            "required": true
          },
          {
            "type": "string",
            "description": "Comma-separated list of fields to return (e.g. query,timestamp,query_time,memory_max,digest)",
            "name": "fields",
            "in": "query",
            "required": true
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "database names to search",
            "name": "db",
            "in": "query"
          },
          {
            "type": "integer",
            "description": "result count limit",
            "name": "limit",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Substring filter on SQL text or digest",
            "name": "text",
            "in": "query"
          },
          {
            "type": "string",
            "description": "order by which field",
            "name": "orderBy",
            "in": "query"
          },
          {
            "type": "boolean",
            "description": "descending order",
            "name": "desc",
            "in": "query"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "plan digests to search",
            "name": "plans",
            "in": "query"
          },
          {
            "type": "string",
            "description": "sql digest to search",
            "name": "digest",
            "in": "query"
          },
          {
            "type": "boolean",
            "description": "show internal slow queries",
            "name": "show_internal",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/slowquery.slowLogRespItem"
              }
            }
          }
        }
      }
    },
    "/slow_query/stats": {
      "get": {
        "description": "Aggregate slow query statistics over time windows, with optional filtering by statement types and databases.",
        "produces": ["application/json"],
        "tags": ["slowquery"],
        "summary": "Get slow query statistics",
        "parameters": [
          {
            "type": "string",
            "description": "Cloud provider for the query: aws or gcp",
            "name": "x-provider",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Cloud region where slow logs are stored",
            "name": "x-region",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Organization ID in TiDB Cloud (if applicable)",
            "name": "x-org-id",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Project ID in TiDB Cloud (if applicable)",
            "name": "x-project-id",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Observability cluster ID for the target TiDB deployment",
            "name": "x-cluster-id",
            "in": "header",
            "required": true
          },
          {
            "type": "integer",
            "description": "hour begin time in unix seconds",
            "name": "begin_time",
            "in": "query",
            "required": true
          },
          {
            "type": "integer",
            "description": "n hours (3/6/12/24/)",
            "name": "hours",
            "in": "query",
            "required": true
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Statement types to include (default: all). Example: [SELECT INSERT]",
            "name": "statement_types",
            "in": "query"
          },
          {
            "type": "boolean",
            "description": "statement types not in, default false",
            "name": "statement_types_not_in",
            "in": "query"
          },
          {
            "type": "string",
            "description": "database name, default empty string for all",
            "name": "database",
            "in": "query"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "database names, default empty array for all",
            "name": "databases",
            "in": "query"
          },
          {
            "type": "string",
            "description": "order by field, default empty string for count",
            "name": "order_by",
            "in": "query"
          },
          {
            "type": "integer",
            "description": "top limit, default 10",
            "name": "limit",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/slowstats.SlowStats"
              }
            }
          }
        }
      }
    },
    "/slow_query/stats/databases": {
      "get": {
        "description": "Return database names present in the aggregated slow query statistics window.",
        "produces": ["application/json"],
        "tags": ["slowquery"],
        "summary": "List databases for slow query statistics",
        "parameters": [
          {
            "type": "string",
            "description": "Cloud provider for the query: aws or gcp",
            "name": "x-provider",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Cloud region where slow logs are stored",
            "name": "x-region",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Organization ID in TiDB Cloud (if applicable)",
            "name": "x-org-id",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Project ID in TiDB Cloud (if applicable)",
            "name": "x-project-id",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Observability cluster ID for the target TiDB deployment",
            "name": "x-cluster-id",
            "in": "header",
            "required": true
          },
          {
            "type": "integer",
            "description": "Hour-aligned begin time (Unix seconds)",
            "name": "begin_time",
            "in": "query",
            "required": true
          },
          {
            "type": "integer",
            "description": "Number of hours to include (3/6/12/24)",
            "name": "hours",
            "in": "query",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        }
      }
    },
    "/slow_query/stats/metric": {
      "get": {
        "description": "Fetch a time series metric aggregated from slow queries.",
        "produces": ["application/json"],
        "tags": ["slowquery"],
        "summary": "Get slow query statistics metric",
        "parameters": [
          {
            "type": "string",
            "description": "Cloud provider for the query: aws or gcp",
            "name": "x-provider",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Cloud region where slow logs are stored",
            "name": "x-region",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Organization ID in TiDB Cloud (if applicable)",
            "name": "x-org-id",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Project ID in TiDB Cloud (if applicable)",
            "name": "x-project-id",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Observability cluster ID for the target TiDB deployment",
            "name": "x-cluster-id",
            "in": "header",
            "required": true
          },
          {
            "type": "integer",
            "description": "Hour-aligned begin time (Unix seconds)",
            "name": "begin_time",
            "in": "query",
            "required": true
          },
          {
            "type": "integer",
            "description": "Number of hours to include (3/6/12/24)",
            "name": "hours",
            "in": "query",
            "required": true
          },
          {
            "type": "string",
            "description": "Metric name. Example: count_per_minute (default)",
            "name": "metric_name",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/slowquery.slowMetricSeriesPoint"
              }
            }
          }
        }
      }
    },
    "/statements/available_fields": {
      "get": {
        "description": "Returns field names for statements APIs. usage=list (default): columns for /statements/list fields param; usage=filter: fields for /statements/field_values and field+values filters.",
        "produces": ["application/json"],
        "tags": ["statements"],
        "summary": "List selectable fields for statements",
        "parameters": [
          {
            "type": "string",
            "description": "Cloud provider",
            "name": "X-Provider",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Cloud region",
            "name": "X-Region",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Organization ID",
            "name": "X-Org-Id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Project ID",
            "name": "X-Project-Id",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Cluster ID",
            "name": "X-Cluster-Id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Deployment tier",
            "name": "X-Deploy-Type",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "list or filter (default: list)",
            "name": "usage",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        }
      }
    },
    "/statements/datasource": {
      "get": {
        "description": "Cheap check that statements v2 Delta Lake data exists (HEAD _delta_log/_last_checkpoint). Use before calling list/summary with data_source=v2.",
        "produces": ["application/json"],
        "tags": ["statements"],
        "summary": "Probe statements v2 data source",
        "parameters": [
          {
            "type": "string",
            "description": "Cloud provider",
            "name": "X-Provider",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Cloud region",
            "name": "X-Region",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Organization ID",
            "name": "X-Org-Id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Project ID",
            "name": "X-Project-Id",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Cluster ID",
            "name": "X-Cluster-Id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Deployment tier",
            "name": "X-Deploy-Type",
            "in": "header",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/sqls.StatementsDataSourcesResponse"
            }
          }
        }
      }
    },
    "/statements/field_values": {
      "get": {
        "description": "Returns distinct values of a field within the time window (JSON string array). Use GET /statements/available_fields?usage=filter for allowed field names.",
        "produces": ["application/json"],
        "tags": ["statements"],
        "summary": "Distinct statement field values",
        "parameters": [
          {
            "type": "string",
            "description": "Cloud provider",
            "name": "X-Provider",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Cloud region",
            "name": "X-Region",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Organization ID",
            "name": "X-Org-Id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Project ID",
            "name": "X-Project-Id",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Cluster ID",
            "name": "X-Cluster-Id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Deployment tier",
            "name": "X-Deploy-Type",
            "in": "header",
            "required": true
          },
          {
            "type": "integer",
            "description": "Start time in Unix seconds (inclusive)",
            "name": "begin_time",
            "in": "query",
            "required": true
          },
          {
            "type": "integer",
            "description": "End time in Unix seconds (inclusive)",
            "name": "end_time",
            "in": "query",
            "required": true
          },
          {
            "type": "string",
            "description": "Field name; see available_fields?usage=filter",
            "name": "field",
            "in": "query",
            "required": true
          },
          {
            "type": "integer",
            "description": "Max distinct values (default 500, max 2000)",
            "name": "limit",
            "in": "query"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by schemas",
            "name": "schemas",
            "in": "query"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by stmt_types",
            "name": "stmt_types",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Substring filter on SQL text or digest",
            "name": "text",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Filter rows by user; use sample_users for multi-select",
            "name": "sample_user",
            "in": "query"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter rows by any of the users (supports sample_users[] / users[])",
            "name": "sample_users",
            "in": "query"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter rows by table_names (supports tables[] / table_names[])",
            "name": "tables",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Narrow rows by another field before distinct",
            "name": "match_field",
            "in": "query"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Values for match_field",
            "name": "match_values",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Additional field filters as JSON array",
            "name": "filters",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        }
      }
    },
    "/statements/list": {
      "get": {
        "description": "Return an overview of SQL statements within a time window. The returned columns depend on the `fields` parameter.",
        "produces": ["application/json"],
        "tags": ["statements"],
        "summary": "List statement overview",
        "parameters": [
          {
            "type": "string",
            "description": "Cloud provider for the query: aws or gcp",
            "name": "X-Provider",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Cloud region where statement data is stored",
            "name": "X-Region",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Organization ID (x-org-id)",
            "name": "X-Org-Id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Project ID in TiDB Cloud (optional; defaults to empty)",
            "name": "X-Project-Id",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Cluster ID (x-cluster-id) of the target TiDB deployment",
            "name": "X-Cluster-Id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Deployment tier: dedicated or shared",
            "name": "X-Deploy-Type",
            "in": "header",
            "required": true
          },
          {
            "type": "integer",
            "description": "Start time in Unix seconds (inclusive)",
            "name": "begin_time",
            "in": "query",
            "required": true
          },
          {
            "type": "integer",
            "description": "End time in Unix seconds (inclusive)",
            "name": "end_time",
            "in": "query",
            "required": true
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "filter by schemas",
            "name": "schemas",
            "in": "query"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "filter by stmt_types",
            "name": "stmt_types",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Substring filter on SQL text or digest",
            "name": "text",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Filter rows by user (v2: key in auth_users; v1: exact sample_user match); use sample_users for multi-select",
            "name": "sample_user",
            "in": "query"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter rows by any of the users (supports sample_users[] / users[])",
            "name": "sample_users",
            "in": "query"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter rows by table_names (supports tables[] / table_names[])",
            "name": "tables",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Filter rows by field; see available_fields?usage=filter",
            "name": "field",
            "in": "query"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Values for field (supports values[])",
            "name": "values",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Additional field filters as JSON array",
            "name": "filters",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Comma-separated list of fields to return. Default includes summary fields.",
            "name": "fields",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "list of statement rows (schema varies by fields param)",
            "schema": {
              "type": "object"
            }
          }
        }
      }
    },
    "/statements/plan/detail": {
      "get": {
        "description": "Returns aggregated detail for a SQL digest, optionally narrowed to specific plan_digest values.",
        "produces": ["application/json"],
        "tags": ["statements"],
        "summary": "Get statement plan detail",
        "parameters": [
          {
            "type": "string",
            "description": "Cloud provider",
            "name": "X-Provider",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Cloud region",
            "name": "X-Region",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Organization ID",
            "name": "X-Org-Id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Project ID",
            "name": "X-Project-Id",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Cluster ID",
            "name": "X-Cluster-Id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Deployment tier",
            "name": "X-Deploy-Type",
            "in": "header",
            "required": true
          },
          {
            "type": "integer",
            "description": "Start time in Unix seconds (inclusive)",
            "name": "begin_time",
            "in": "query",
            "required": true
          },
          {
            "type": "integer",
            "description": "End time in Unix seconds (inclusive)",
            "name": "end_time",
            "in": "query",
            "required": true
          },
          {
            "type": "string",
            "description": "Filter by schema name (substring match)",
            "name": "schema_name",
            "in": "query"
          },
          {
            "type": "string",
            "description": "SQL digest",
            "name": "digest",
            "in": "query",
            "required": true
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by plan_digest values (supports plans[])",
            "name": "plans",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Data source identifier",
            "name": "dataSource",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Data source identifier (alias)",
            "name": "data_source",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "aggregated statement detail row",
            "schema": {
              "type": "object"
            }
          }
        }
      }
    },
    "/statements/plans": {
      "get": {
        "description": "Returns plan-level aggregates for a SQL digest within a time window. One row per plan_digest.",
        "produces": ["application/json"],
        "tags": ["statements"],
        "summary": "List execution plans for a statement",
        "parameters": [
          {
            "type": "string",
            "description": "Cloud provider",
            "name": "X-Provider",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Cloud region",
            "name": "X-Region",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Organization ID",
            "name": "X-Org-Id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Project ID",
            "name": "X-Project-Id",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Cluster ID",
            "name": "X-Cluster-Id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Deployment tier",
            "name": "X-Deploy-Type",
            "in": "header",
            "required": true
          },
          {
            "type": "integer",
            "description": "Start time in Unix seconds (inclusive)",
            "name": "begin_time",
            "in": "query",
            "required": true
          },
          {
            "type": "integer",
            "description": "End time in Unix seconds (inclusive)",
            "name": "end_time",
            "in": "query",
            "required": true
          },
          {
            "type": "string",
            "description": "Filter by schema name (substring match)",
            "name": "schema_name",
            "in": "query"
          },
          {
            "type": "string",
            "description": "SQL digest",
            "name": "digest",
            "in": "query",
            "required": true
          },
          {
            "type": "string",
            "description": "Data source identifier",
            "name": "dataSource",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Data source identifier (alias)",
            "name": "data_source",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "plan rows grouped by digest and plan_digest",
            "schema": {
              "type": "array",
              "items": {
                "type": "object"
              }
            }
          }
        }
      }
    },
    "/statements/stmt_types": {
      "get": {
        "description": "Returns supported SQL statement types for statements filtering.",
        "produces": ["application/json"],
        "tags": ["statements"],
        "summary": "List statement types",
        "parameters": [
          {
            "type": "string",
            "description": "Cloud provider",
            "name": "X-Provider",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Cloud region",
            "name": "X-Region",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Organization ID",
            "name": "X-Org-Id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Project ID",
            "name": "X-Project-Id",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Cluster ID",
            "name": "X-Cluster-Id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Deployment tier",
            "name": "X-Deploy-Type",
            "in": "header",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        }
      }
    },
    "/statements/summary": {
      "get": {
        "description": "Returns top-N summary with time-bucketed series (TopRU-like response shape). Group by dimension (default digest).",
        "produces": ["application/json"],
        "tags": ["statements"],
        "summary": "Statements summary statistics",
        "parameters": [
          {
            "type": "string",
            "description": "Cloud provider",
            "name": "X-Provider",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Cloud region",
            "name": "X-Region",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Organization ID",
            "name": "X-Org-Id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Project ID",
            "name": "X-Project-Id",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Cluster ID",
            "name": "X-Cluster-Id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Deployment tier",
            "name": "X-Deploy-Type",
            "in": "header",
            "required": true
          },
          {
            "type": "integer",
            "description": "Start time in Unix seconds (inclusive)",
            "name": "begin_time",
            "in": "query",
            "required": true
          },
          {
            "type": "integer",
            "description": "End time in Unix seconds (inclusive)",
            "name": "end_time",
            "in": "query",
            "required": true
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by schemas",
            "name": "schemas",
            "in": "query"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by stmt_types",
            "name": "stmt_types",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Substring filter on SQL text or digest",
            "name": "text",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Filter rows by user (v2: auth_users key; v1: sample_user); use sample_users for multi-select",
            "name": "sample_user",
            "in": "query"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter rows by any of the users (supports sample_users[] / users[])",
            "name": "sample_users",
            "in": "query"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter rows by table_names (supports tables[] / table_names[])",
            "name": "tables",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Filter rows by field; see available_fields?usage=filter",
            "name": "field",
            "in": "query"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Values for field (supports values[])",
            "name": "values",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Additional field filters as JSON array, e.g. [{\\",
            "name": "filters",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Top N for each ranking list (default 20)",
            "name": "top",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Sort metric from available fields (numeric subset), e.g. sum_ru|sum_ru_v2|exec_count|sum_latency",
            "name": "order_by",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Group dimension: user | sqltypes | digest | db | table (default: digest)",
            "name": "dimension",
            "in": "query"
          },
          {
            "type": "integer",
            "description": "Time bucket size in seconds (default: 60)",
            "name": "step",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/sqls.StatementsSummaryEnvelope"
            }
          }
        }
      }
    },
    "/statements/time_ranges": {
      "get": {
        "description": "Placeholder endpoint for statements time range metadata. Currently returns an empty response.",
        "produces": ["text/plain"],
        "tags": ["statements"],
        "summary": "Get statements time ranges",
        "parameters": [
          {
            "type": "string",
            "description": "Cloud provider",
            "name": "X-Provider",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Cloud region",
            "name": "X-Region",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Organization ID",
            "name": "X-Org-Id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Project ID",
            "name": "X-Project-Id",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Cluster ID",
            "name": "X-Cluster-Id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Deployment tier",
            "name": "X-Deploy-Type",
            "in": "header",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "type": "string"
            }
          }
        }
      }
    },
    "/statements/topstats": {
      "get": {
        "description": "Returns ranking list grouped by one dimension: user, sqltypes, digest, db (database/schema name), or table.",
        "produces": ["application/json"],
        "tags": ["statements"],
        "summary": "Statements top statistics",
        "parameters": [
          {
            "type": "string",
            "description": "Cloud provider",
            "name": "X-Provider",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Cloud region",
            "name": "X-Region",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Organization ID",
            "name": "X-Org-Id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Project ID",
            "name": "X-Project-Id",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Cluster ID",
            "name": "X-Cluster-Id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Deployment tier",
            "name": "X-Deploy-Type",
            "in": "header",
            "required": true
          },
          {
            "type": "integer",
            "description": "Start time in Unix seconds (inclusive)",
            "name": "begin_time",
            "in": "query",
            "required": true
          },
          {
            "type": "integer",
            "description": "End time in Unix seconds (inclusive)",
            "name": "end_time",
            "in": "query",
            "required": true
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by schemas",
            "name": "schemas",
            "in": "query"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by stmt_types",
            "name": "stmt_types",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Substring filter on SQL text or digest",
            "name": "text",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Filter rows by user (v2: auth_users key; v1: sample_user); use sample_users for multi-select",
            "name": "sample_user",
            "in": "query"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter rows by any of the users (supports sample_users[] / users[])",
            "name": "sample_users",
            "in": "query"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter rows by table_names (supports tables[] / table_names[])",
            "name": "tables",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Filter rows by field; see available_fields?usage=filter",
            "name": "field",
            "in": "query"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Values for field (supports values[])",
            "name": "values",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Additional field filters as JSON array, e.g. [{\\",
            "name": "filters",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Top N rows (default 20)",
            "name": "top",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Group dimension: user | sqltypes | digest | db | table (default: digest)",
            "name": "dimension",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Sort metric from available fields (numeric subset), e.g. sum_ru|sum_ru_v2|exec_count|sum_latency",
            "name": "order_by",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/sqls.StatementsTopStatsEnvelope"
            }
          }
        }
      }
    },
    "/topru/config": {
      "get": {
        "description": "TopRU is always enabled when using Delta Lake data source",
        "produces": ["application/json"],
        "tags": ["topru"],
        "summary": "Get config of TopRU",
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/topru.configResponse"
            }
          }
        }
      }
    },
    "/topru/summary": {
      "get": {
        "description": "Aggregate ReadUnits (RU) grouped by sql_digest within the given time range. Plans are collapsed into one row per digest. Use /topru/summaryplan?digest=… for plan breakdown.",
        "produces": ["application/json"],
        "tags": ["topru"],
        "summary": "Get TopRU summary (RU by SQL digest)",
        "parameters": [
          {
            "type": "string",
            "description": "Cloud provider where RU data is stored (aws/gcp/azure)",
            "name": "X-Provider",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Cloud region where RU data is stored",
            "name": "X-Region",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Organization ID (x-org-id)",
            "name": "X-Org-Id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Project ID (x-project-id; optional)",
            "name": "X-Project-Id",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Cluster ID (x-cluster-id)",
            "name": "X-Cluster-Id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Deployment tier: dedicated/shared/nextgen/premium",
            "name": "X-Deploy-Type",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Start time in Unix seconds (inclusive)",
            "name": "start",
            "in": "query",
            "required": true
          },
          {
            "type": "string",
            "description": "End time in Unix seconds (inclusive)",
            "name": "end",
            "in": "query",
            "required": true
          },
          {
            "type": "string",
            "description": "Top N SQL digests to return",
            "name": "top",
            "in": "query",
            "required": true
          },
          {
            "type": "string",
            "description": "Metric used to rank results: ru | exec_count | duration (default: ru)",
            "name": "order_by",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Omit to not filter by user. Pass empty (user=) to keep only rows with empty or NULL user; pass a name to filter by that user",
            "name": "user",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Data source identifier (expected: deltalake)",
            "name": "data_source",
            "in": "query"
          },
          {
            "type": "integer",
            "description": "Bucket size in seconds. Default: 60",
            "name": "step",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/topru.summaryEnvelope"
            }
          }
        }
      }
    },
    "/topru/summaryplan": {
      "get": {
        "description": "Aggregate ReadUnits (RU) grouped by sql_digest and plan_digest. Optionally filter to one sql_digest via digest=.",
        "produces": ["application/json"],
        "tags": ["topru"],
        "summary": "Get TopRU summary by plan (RU by SQL/plan digest)",
        "parameters": [
          {
            "type": "string",
            "description": "Cloud provider where RU data is stored (aws/gcp/azure)",
            "name": "X-Provider",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Cloud region where RU data is stored",
            "name": "X-Region",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Organization ID (x-org-id)",
            "name": "X-Org-Id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Project ID (x-project-id; optional)",
            "name": "X-Project-Id",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Cluster ID (x-cluster-id)",
            "name": "X-Cluster-Id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Deployment tier: dedicated/shared/nextgen/premium",
            "name": "X-Deploy-Type",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Start time in Unix seconds (inclusive)",
            "name": "start",
            "in": "query",
            "required": true
          },
          {
            "type": "string",
            "description": "End time in Unix seconds (inclusive)",
            "name": "end",
            "in": "query",
            "required": true
          },
          {
            "type": "string",
            "description": "Top N SQL/plan groups to return",
            "name": "top",
            "in": "query",
            "required": true
          },
          {
            "type": "string",
            "description": "Filter to a single sql_digest (drill-down from /topru/summary)",
            "name": "digest",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Metric used to rank results: ru | exec_count | duration (default: ru)",
            "name": "order_by",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Omit to not filter by user. Pass empty (user=) to keep only rows with empty or NULL user; pass a name to filter by that user",
            "name": "user",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Data source identifier (expected: deltalake)",
            "name": "data_source",
            "in": "query"
          },
          {
            "type": "integer",
            "description": "Bucket size in seconds. Default: 60",
            "name": "step",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/topru.summaryPlanEnvelope"
            }
          }
        }
      }
    },
    "/topru/user_stats": {
      "get": {
        "description": "Aggregate RU and execution stats grouped by user over the given time range.",
        "produces": ["application/json"],
        "tags": ["topru"],
        "summary": "Get TopRU user statistics (RU per user)",
        "parameters": [
          {
            "type": "string",
            "description": "Cloud provider where RU data is stored (aws/gcp/azure)",
            "name": "X-Provider",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Cloud region where RU data is stored",
            "name": "X-Region",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Organization ID (x-org-id)",
            "name": "X-Org-Id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Project ID (x-project-id; optional)",
            "name": "X-Project-Id",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Cluster ID (x-cluster-id)",
            "name": "X-Cluster-Id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Deployment tier",
            "name": "X-Deploy-Type",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Start time in Unix seconds (inclusive)",
            "name": "start",
            "in": "query",
            "required": true
          },
          {
            "type": "string",
            "description": "End time in Unix seconds (inclusive)",
            "name": "end",
            "in": "query",
            "required": true
          },
          {
            "type": "string",
            "description": "Top N users to return (default: 20)",
            "name": "top",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/topru.userStatsEnvelope"
            }
          }
        }
      }
    },
    "/topsql/config": {
      "get": {
        "description": "Return the TopSQL feature configuration for diagnosis queries.",
        "produces": ["application/json"],
        "tags": ["topsql"],
        "summary": "Get TopSQL configuration",
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/topsql.configResponse"
            }
          }
        }
      }
    },
    "/topsql/instances": {
      "get": {
        "description": "List TopSQL instances that have data within the given time window.",
        "produces": ["application/json"],
        "tags": ["topsql"],
        "summary": "Get available TopSQL instances",
        "parameters": [
          {
            "type": "string",
            "description": "Cloud provider where TopSQL data is stored (aws or gcp)",
            "name": "X-Provider",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Cloud region where TopSQL data is stored",
            "name": "X-Region",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Organization ID (x-org-id) used to locate TopSQL data",
            "name": "X-Org-Id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Project ID in TiDB Cloud (optional)",
            "name": "X-Project-Id",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Cluster ID (x-cluster-id) of the target TiDB deployment",
            "name": "X-Cluster-Id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Start time in Unix seconds (inclusive)",
            "name": "start",
            "in": "query",
            "required": true
          },
          {
            "type": "string",
            "description": "End time in Unix seconds (inclusive)",
            "name": "end",
            "in": "query",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/topsql.instancesEnvelope"
            }
          }
        }
      }
    },
    "/topsql/summary": {
      "get": {
        "description": "Return aggregated TopSQL summary for a given time window and instance filter.",
        "produces": ["application/json"],
        "tags": ["topsql"],
        "summary": "Get TopSQL summary",
        "parameters": [
          {
            "type": "string",
            "description": "Cloud provider where TopSQL data is stored (aws or gcp)",
            "name": "X-Provider",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Cloud region where TopSQL data is stored",
            "name": "X-Region",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Organization ID (x-org-id) used to locate TopSQL data",
            "name": "X-Org-Id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Project ID in TiDB Cloud (optional)",
            "name": "X-Project-Id",
            "in": "header"
          },
          {
            "type": "string",
            "description": "Cluster ID (x-cluster-id) of the target TiDB deployment",
            "name": "X-Cluster-Id",
            "in": "header",
            "required": true
          },
          {
            "type": "string",
            "description": "Start time in Unix seconds (inclusive)",
            "name": "start",
            "in": "query",
            "required": true
          },
          {
            "type": "string",
            "description": "End time in Unix seconds (inclusive)",
            "name": "end",
            "in": "query",
            "required": true
          },
          {
            "type": "string",
            "description": "Aggregation window duration (e.g. 5m, 1h)",
            "name": "window",
            "in": "query",
            "required": true
          },
          {
            "type": "integer",
            "description": "Top N results to return",
            "name": "top",
            "in": "query",
            "required": true
          },
          {
            "type": "string",
            "description": "Instance name filter (e.g. tidb_instance_1)",
            "name": "instance",
            "in": "query",
            "required": true
          },
          {
            "type": "string",
            "description": "Instance type filter (e.g. tidb, tikv, pd)",
            "name": "instance_type",
            "in": "query",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/topsql.summaryEnvelope"
            }
          }
        }
      }
    }
  },
  "definitions": {
    "api.InstanceItem": {
      "type": "object",
      "properties": {
        "instance": {
          "type": "string"
        },
        "instance_type": {
          "type": "string"
        }
      }
    },
    "api.SummaryItem": {
      "type": "object",
      "properties": {
        "cpu_time_ms": {
          "type": "integer"
        },
        "duration_per_exec_ms": {
          "type": "number"
        },
        "exec_count_per_sec": {
          "type": "number"
        },
        "is_other": {
          "type": "boolean"
        },
        "plans": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/api.SummaryPlanItem"
          }
        },
        "scan_indexes_per_sec": {
          "type": "number"
        },
        "scan_records_per_sec": {
          "type": "number"
        },
        "sql_digest": {
          "type": "string"
        },
        "sql_text": {
          "type": "string"
        }
      }
    },
    "api.SummaryPlanItem": {
      "type": "object",
      "properties": {
        "cpu_time_ms": {
          "type": "array",
          "items": {
            "type": "integer"
          }
        },
        "duration_per_exec_ms": {
          "type": "number"
        },
        "exec_count_per_sec": {
          "type": "number"
        },
        "plan_digest": {
          "type": "string"
        },
        "plan_text": {
          "type": "string"
        },
        "scan_indexes_per_sec": {
          "type": "number"
        },
        "scan_records_per_sec": {
          "type": "number"
        },
        "timestamp_sec": {
          "type": "array",
          "items": {
            "type": "integer"
          }
        }
      }
    },
    "conprof.detailResponse": {
      "type": "object",
      "properties": {
        "profile_duration_secs": {
          "type": "integer"
        },
        "state": {
          "type": "string"
        },
        "target_profiles": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/conprof.detailResponseProfile"
          }
        },
        "ts": {
          "type": "integer"
        }
      }
    },
    "conprof.detailResponseProfile": {
      "type": "object",
      "properties": {
        "error": {
          "type": "string"
        },
        "profile_type": {
          "type": "string"
        },
        "state": {
          "type": "string"
        },
        "target": {
          "type": "object",
          "$ref": "#/definitions/conprof.detailResponseProfileTarget"
        }
      }
    },
    "conprof.detailResponseProfileTarget": {
      "type": "object",
      "properties": {
        "address": {
          "type": "string"
        },
        "component": {
          "type": "string"
        }
      }
    },
    "conprof.listResponseItem": {
      "type": "object",
      "properties": {
        "component_num": {
          "type": "object",
          "additionalProperties": {
            "type": "integer"
          }
        },
        "profile_duration_secs": {
          "type": "integer"
        },
        "state": {
          "type": "string"
        },
        "ts": {
          "type": "integer"
        }
      }
    },
    "k.LabelKey": {
      "type": "object",
      "required": ["key", "labels"],
      "properties": {
        "key": {
          "type": "string"
        },
        "labels": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "k.Matrix": {
      "type": "object",
      "required": ["data", "keyAxis", "timeAxis"],
      "properties": {
        "data": {
          "type": "object",
          "additionalProperties": {
            "type": "array",
            "items": {
              "type": "array",
              "items": {
                "type": "integer"
              }
            }
          }
        },
        "keyAxis": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/k.LabelKey"
          }
        },
        "timeAxis": {
          "type": "array",
          "items": {
            "type": "integer"
          }
        }
      }
    },
    "keyviz.KeyVisualConfig": {
      "type": "object",
      "properties": {
        "auto_collection_disabled": {
          "type": "boolean"
        },
        "policy": {
          "type": "string"
        },
        "policy_kv_separator": {
          "type": "string"
        }
      }
    },
    "slowquery.slowLogRespItem": {
      "type": "object",
      "properties": {
        "backoff_time": {
          "type": "number"
        },
        "backoff_types": {
          "type": "string"
        },
        "commit_backoff_time": {
          "type": "number"
        },
        "commit_time": {
          "type": "number"
        },
        "compile_time": {
          "type": "number"
        },
        "connection_id": {
          "description": "TODO: Switch back to uint64 when modern browser as well as Swagger handles BigInt well.",
          "type": "string"
        },
        "cop_proc_addr": {
          "type": "string"
        },
        "cop_proc_avg": {
          "type": "number"
        },
        "cop_proc_max": {
          "type": "number"
        },
        "cop_proc_p90": {
          "type": "number"
        },
        "cop_time": {
          "type": "number"
        },
        "cop_wait_addr": {
          "type": "string"
        },
        "cop_wait_avg": {
          "type": "number"
        },
        "cop_wait_max": {
          "type": "number"
        },
        "cop_wait_p90": {
          "type": "number"
        },
        "db": {
          "type": "string"
        },
        "digest": {
          "type": "string"
        },
        "disk_max": {
          "type": "integer"
        },
        "exec_retry_time": {
          "type": "number"
        },
        "get_commit_ts_time": {
          "type": "number"
        },
        "host": {
          "type": "string"
        },
        "index_names": {
          "type": "string"
        },
        "instance": {
          "type": "string"
        },
        "is_internal": {
          "description": "Basic",
          "type": "integer"
        },
        "local_latch_wait_time": {
          "type": "number"
        },
        "lock_keys_time": {
          "type": "number"
        },
        "memory_max": {
          "type": "integer"
        },
        "optimize_time": {
          "type": "number"
        },
        "parse_time": {
          "type": "number"
        },
        "plan": {
          "type": "string"
        },
        "plan_from_binding": {
          "type": "integer"
        },
        "plan_from_cache": {
          "type": "integer"
        },
        "prepared": {
          "type": "integer"
        },
        "preproc_subqueries_time": {
          "type": "number"
        },
        "prev_stmt": {
          "description": "Detail",
          "type": "string"
        },
        "prewrite_region": {
          "type": "integer"
        },
        "prewrite_time": {
          "type": "number"
        },
        "process_keys": {
          "type": "integer"
        },
        "process_time": {
          "description": "Time",
          "type": "number"
        },
        "query": {
          "type": "string"
        },
        "query_time": {
          "description": "latency",
          "type": "number"
        },
        "request_count": {
          "description": "Coprocessor",
          "type": "integer"
        },
        "resolve_lock_time": {
          "type": "number"
        },
        "resource_group": {
          "type": "string"
        },
        "rewrite_time": {
          "type": "number"
        },
        "rocksdb_block_cache_hit_count": {
          "type": "integer"
        },
        "rocksdb_block_read_byte": {
          "type": "integer"
        },
        "rocksdb_block_read_count": {
          "type": "integer"
        },
        "rocksdb_delete_skipped_count": {
          "description": "RocksDB",
          "type": "integer"
        },
        "rocksdb_key_skipped_count": {
          "type": "integer"
        },
        "ru": {
          "description": "Resource Control",
          "type": "number"
        },
        "ru_v2": {
          "type": "number"
        },
        "stats": {
          "type": "string"
        },
        "success": {
          "type": "integer"
        },
        "tidb_cpu_time": {
          "type": "number"
        },
        "tikv_cpu_time": {
          "type": "number"
        },
        "time_queued_by_rc": {
          "type": "number"
        },
        "timestamp": {
          "description": "finish time",
          "type": "number"
        },
        "total_keys": {
          "type": "integer"
        },
        "txn_retry": {
          "type": "integer"
        },
        "txn_start_ts": {
          "description": "TODO: Switch back to uint64 when modern browser as well as Swagger handles BigInt well.",
          "type": "string"
        },
        "user": {
          "description": "Connection",
          "type": "string"
        },
        "wait_prewrite_binlog_time": {
          "type": "number"
        },
        "wait_time": {
          "type": "number"
        },
        "wait_ts": {
          "type": "number"
        },
        "warnings": {
          "type": "string"
        },
        "write_keys": {
          "description": "Transaction",
          "type": "integer"
        },
        "write_size": {
          "type": "integer"
        },
        "write_sql_response_total": {
          "type": "number"
        }
      }
    },
    "slowquery.slowMetricSeriesPoint": {
      "type": "array",
      "items": {
        "type": "integer"
      }
    },
    "slowstats.SlowStats": {
      "type": "object",
      "properties": {
        "avg_disk": {
          "type": "number"
        },
        "avg_latency": {
          "type": "number"
        },
        "avg_memory": {
          "type": "number"
        },
        "count": {
          "type": "integer"
        },
        "db": {
          "type": "string"
        },
        "max_disk": {
          "type": "number"
        },
        "max_latency": {
          "type": "number"
        },
        "max_memory": {
          "type": "number"
        },
        "sql_digest": {
          "type": "string"
        },
        "sql_text": {
          "type": "string"
        },
        "statement_type": {
          "type": "string"
        },
        "sum_disk": {
          "type": "number"
        },
        "sum_latency": {
          "type": "number"
        },
        "sum_memory": {
          "type": "number"
        }
      }
    },
    "sqls.StatementsDataSourcesResponse": {
      "type": "object",
      "properties": {
        "v2_available": {
          "type": "boolean"
        }
      }
    },
    "sqls.StatementsSummaryEnvelope": {
      "type": "object",
      "properties": {
        "data": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/sqls.StatementsSummaryItem"
          }
        },
        "status": {
          "type": "string"
        }
      }
    },
    "sqls.StatementsSummaryItem": {
      "type": "object",
      "properties": {
        "db": {
          "type": "string"
        },
        "dimension": {
          "type": "string"
        },
        "duration_ns": {
          "type": "integer"
        },
        "duration_per_exec_ms": {
          "type": "number"
        },
        "exec_count": {
          "type": "integer"
        },
        "exec_count_per_sec": {
          "type": "number"
        },
        "is_other": {
          "type": "boolean"
        },
        "order_metric": {
          "description": "OrderMetric is the digest-level value used for Top N ranking (same as top_digests.order_metric).",
          "type": "number"
        },
        "plan_digest": {
          "type": "string"
        },
        "sql_digest": {
          "type": "string"
        },
        "sql_text": {
          "type": "string"
        },
        "stmt_type": {
          "type": "string"
        },
        "table": {
          "type": "string"
        },
        "timestamp_sec": {
          "type": "array",
          "items": {
            "type": "integer"
          }
        },
        "total_ru": {
          "type": "number"
        },
        "user": {
          "type": "string"
        },
        "value_by_time": {
          "description": "ValueByTime is one value per time_bucket, aggregated with the same expression as order_by (e.g. sum_ru, exec_count, sum_latency).",
          "type": "array",
          "items": {
            "type": "number"
          }
        }
      }
    },
    "sqls.StatementsTopStatsEnvelope": {
      "type": "object",
      "properties": {
        "data": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/sqls.StatementsTopStatsItem"
          }
        },
        "status": {
          "type": "string"
        }
      }
    },
    "sqls.StatementsTopStatsItem": {
      "type": "object",
      "properties": {
        "db": {
          "type": "string"
        },
        "digest_text": {
          "type": "string"
        },
        "dimension": {
          "type": "string"
        },
        "exec_count": {
          "type": "integer"
        },
        "key": {
          "description": "Compatibility field; prefer dimension-specific fields below.",
          "type": "string"
        },
        "order_by": {
          "type": "string"
        },
        "plan_count": {
          "type": "integer"
        },
        "query_sample_text": {
          "type": "string"
        },
        "sql_digest": {
          "type": "string"
        },
        "stmt_type": {
          "type": "string"
        },
        "sum_latency": {
          "type": "integer"
        },
        "table": {
          "type": "string"
        },
        "total_ru": {
          "description": "Compatibility field; total_ru is only populated when order_by is sum_ru or sum_ru_v2.",
          "type": "number"
        },
        "user": {
          "type": "string"
        },
        "value": {
          "type": "number"
        }
      }
    },
    "topru.TopRUSummaryItem": {
      "type": "object",
      "properties": {
        "duration_ns": {
          "type": "integer"
        },
        "duration_per_exec_ms": {
          "type": "number"
        },
        "exec_count": {
          "type": "integer"
        },
        "exec_count_per_sec": {
          "type": "number"
        },
        "sql_digest": {
          "type": "string"
        },
        "sql_text": {
          "type": "string"
        },
        "timestamp_sec": {
          "type": "array",
          "items": {
            "type": "integer"
          }
        },
        "total_ru": {
          "type": "number"
        },
        "total_ru_by_time": {
          "type": "array",
          "items": {
            "type": "number"
          }
        }
      }
    },
    "topru.TopRUSummaryPlanItem": {
      "type": "object",
      "properties": {
        "duration_ns": {
          "type": "integer"
        },
        "duration_per_exec_ms": {
          "type": "number"
        },
        "exec_count": {
          "type": "integer"
        },
        "exec_count_per_sec": {
          "type": "number"
        },
        "plan_digest": {
          "type": "string"
        },
        "plan_text": {
          "type": "string"
        },
        "sql_digest": {
          "type": "string"
        },
        "sql_text": {
          "type": "string"
        },
        "timestamp_sec": {
          "type": "array",
          "items": {
            "type": "integer"
          }
        },
        "total_ru": {
          "type": "number"
        },
        "total_ru_by_time": {
          "type": "array",
          "items": {
            "type": "number"
          }
        }
      }
    },
    "topru.UserStatsItem": {
      "type": "object",
      "properties": {
        "duration_ns": {
          "type": "integer"
        },
        "exec_count": {
          "type": "integer"
        },
        "total_ru": {
          "type": "number"
        },
        "user": {
          "type": "string"
        }
      }
    },
    "topru.configResponse": {
      "type": "object",
      "properties": {
        "enable": {
          "type": "boolean"
        }
      }
    },
    "topru.summaryEnvelope": {
      "type": "object",
      "properties": {
        "data": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/topru.TopRUSummaryItem"
          }
        },
        "status": {
          "type": "string"
        }
      }
    },
    "topru.summaryPlanEnvelope": {
      "type": "object",
      "properties": {
        "data": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/topru.TopRUSummaryPlanItem"
          }
        },
        "status": {
          "type": "string"
        }
      }
    },
    "topru.userStatsEnvelope": {
      "type": "object",
      "properties": {
        "data": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/topru.UserStatsItem"
          }
        },
        "status": {
          "type": "string"
        }
      }
    },
    "topsql.configResponse": {
      "type": "object",
      "properties": {
        "enable": {
          "type": "boolean"
        }
      }
    },
    "topsql.instancesEnvelope": {
      "type": "object",
      "properties": {
        "data": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/api.InstanceItem"
          }
        },
        "status": {
          "type": "string"
        }
      }
    },
    "topsql.summaryEnvelope": {
      "type": "object",
      "properties": {
        "data": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/api.SummaryItem"
          }
        },
        "status": {
          "type": "string"
        }
      }
    },
    "topsqlv2.InstanceItem": {
      "type": "object",
      "properties": {
        "instance": {
          "type": "string"
        },
        "instance_type": {
          "type": "string"
        }
      }
    },
    "topsqlv2.SummaryByItem": {
      "type": "object",
      "properties": {
        "cpu_time_ms": {
          "type": "array",
          "items": {
            "type": "integer"
          }
        },
        "cpu_time_ms_sum": {
          "type": "integer"
        },
        "logical_io_bytes": {
          "type": "array",
          "items": {
            "type": "integer"
          }
        },
        "logical_io_bytes_sum": {
          "type": "integer"
        },
        "network_bytes": {
          "type": "array",
          "items": {
            "type": "integer"
          }
        },
        "network_bytes_sum": {
          "type": "integer"
        },
        "text": {
          "type": "string"
        },
        "timestamp_sec": {
          "type": "array",
          "items": {
            "type": "integer"
          }
        }
      }
    },
    "topsqlv2.SummaryItem": {
      "type": "object",
      "properties": {
        "cpu_time_ms": {
          "type": "integer"
        },
        "duration_per_exec_ms": {
          "type": "number"
        },
        "exec_count_per_sec": {
          "type": "number"
        },
        "is_other": {
          "type": "boolean"
        },
        "keyspace": {
          "description": "Keyspace is set for premium TiKV summaries so callers can map a query to its TiDB cluster.",
          "type": "string"
        },
        "logical_io_bytes": {
          "type": "integer"
        },
        "network_bytes": {
          "type": "integer"
        },
        "plans": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/topsqlv2.SummaryPlanItem"
          }
        },
        "scan_indexes_per_sec": {
          "type": "number"
        },
        "scan_records_per_sec": {
          "type": "number"
        },
        "sql_digest": {
          "type": "string"
        },
        "sql_text": {
          "type": "string"
        }
      }
    },
    "topsqlv2.SummaryPlanItem": {
      "type": "object",
      "properties": {
        "cpu_time_ms": {
          "type": "array",
          "items": {
            "type": "integer"
          }
        },
        "duration_per_exec_ms": {
          "type": "number"
        },
        "exec_count_per_sec": {
          "type": "number"
        },
        "logical_io_bytes": {
          "type": "array",
          "items": {
            "type": "integer"
          }
        },
        "network_bytes": {
          "type": "array",
          "items": {
            "type": "integer"
          }
        },
        "plan_digest": {
          "type": "string"
        },
        "plan_text": {
          "type": "string"
        },
        "scan_indexes_per_sec": {
          "type": "number"
        },
        "scan_records_per_sec": {
          "type": "number"
        },
        "timestamp_sec": {
          "type": "array",
          "items": {
            "type": "integer"
          }
        }
      }
    },
    "topsqlv2.configResponse": {
      "type": "object",
      "properties": {
        "enable": {
          "type": "boolean"
        }
      }
    },
    "topsqlv2.instancesEnvelope": {
      "type": "object",
      "properties": {
        "data": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/topsqlv2.InstanceItem"
          }
        },
        "status": {
          "type": "string"
        }
      }
    },
    "topsqlv2.summaryEnvelope": {
      "type": "object",
      "properties": {
        "data": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/topsqlv2.SummaryItem"
          }
        },
        "data_by": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/topsqlv2.SummaryByItem"
          }
        },
        "status": {
          "type": "string"
        }
      }
    }
  }
}
