{
  "openapi": "3.1.0",
  "info": {
    "title": "Fluxgate API",
    "version": "1.0.0",
    "summary": "High-volume telemetry ingestion and query.",
    "description": "Fluxgate accepts batches of metric points, aggregates them into time windows\nasynchronously, and serves the rollups back.\n\nWrites and reads are served by **separate processes** on separate ports.\nThey share this contract, the error format and the credentials, but they\nscale on different axes and fail in different ways: an expensive dashboard\nquery should not slow telemetry ingestion, and an ingest spike should not\nmake dashboards unreadable.\n\n## Error format\n\nEvery failure — including a 404 from the router itself — is an RFC 9457\nproblem document with `Content-Type: application/problem+json`. Branch on\nthe stable `code` field rather than on the prose in `detail`.\n\n## Partial success\n\n`POST /v1/ingest` is deliberately partial-success. A batch containing one\ninvalid point admits the rest and reports the failure, because a single\nmisbehaving call site in a client should not be able to blind an entire\nservice's telemetry. Check `rejected` and `errors` on every 202; a 202 does\nnot mean every point was accepted.\n\n## Retries\n\nA request that times out may or may not have been processed. Send an\n`Idempotency-Key` and repeat the identical body: the original outcome is\nreplayed rather than the batch being counted twice. Reusing a key with a\ndifferent body is a 409, because replaying the first response would\nsilently discard the second batch.\n\nRetry identity is scoped to the authenticated tenant and fingerprints the\nexact body bytes, including JSON whitespace/order. Reservations expire\nafter a configured TTL (24 hours by default, measured from initial\nreservation). Staging/prod uses shared PostgreSQL reservations. After\nexpiry, reusing a key can create a new batch. A 202 confirms publication,\nnot immediate query visibility. See docs/api.md for client integration.\n",
    "license": {
      "name": "MIT",
      "url": "https://github.com/jon-jc/fluxgate/blob/main/LICENSE"
    }
  },
  "servers": [
    {
      "url": "http://localhost:8080",
      "description": "Ingest API (local development)"
    },
    {
      "url": "http://localhost:8082",
      "description": "Query API (local development)"
    },
    {
      "url": "http://localhost:8081",
      "description": "Aggregator operations endpoints only (local development)"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Ingestion",
      "description": "Submitting telemetry. Served by the ingest API."
    },
    {
      "name": "Query",
      "description": "Reading aggregated telemetry back. Served by the query API."
    },
    {
      "name": "Operations",
      "description": "Probes and build metadata. Not part of the versioned contract."
    }
  ],
  "paths": {
    "/v1/ingest": {
      "servers": [
        {
          "url": "http://localhost:8080",
          "description": "Local ingest API; replace with the deployed ingest URL."
        }
      ],
      "post": {
        "tags": [
          "Ingestion"
        ],
        "operationId": "ingestPoints",
        "summary": "Submit a batch of metric points.",
        "description": "Accepts up to 1000 points per request. Points are validated\nindividually; valid ones are admitted even when others in the same\nbatch fail.\n\nQuota is metered in points per second, not requests per second, so\nbatching does not change how much of a tenant's allowance a given\nvolume of data consumes.\n",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "An opaque, client-chosen identifier for this batch. Repeating a\nrequest with the same key and the same body replays the original\nresponse instead of processing the batch again. The default\nlifetime is 24 hours from initial reservation. Preserve exact body\nbytes across ambiguous failures; a new key can duplicate a publish.\n",
            "schema": {
              "type": "string",
              "maxLength": 255,
              "pattern": "^[\\x21-\\x7e]+$"
            },
            "example": "batch-2026-09-03T12:00:00Z-0001"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IngestRequest"
              },
              "examples": {
                "mixed": {
                  "summary": "Three points of different kinds",
                  "value": {
                    "points": [
                      {
                        "metric": "http.request.duration_ms",
                        "kind": "histogram",
                        "value": 12.5,
                        "timestamp": "2026-09-03T12:00:00Z",
                        "labels": {
                          "service": "checkout",
                          "region": "us-central1"
                        }
                      },
                      {
                        "metric": "http.requests",
                        "kind": "counter",
                        "value": 1,
                        "labels": {
                          "service": "checkout",
                          "status": "200"
                        }
                      },
                      {
                        "metric": "queue.depth",
                        "kind": "gauge",
                        "value": 42
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "The batch was accepted for delivery. Inspect `rejected` and\n`errors`: some points may have been dropped.\n",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/XRateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/XRateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/XRateLimitReset"
              },
              "Idempotency-Replayed": {
                "description": "Present and `true` when this response was replayed from a stored outcome.",
                "schema": {
                  "type": "string",
                  "enum": [
                    "true"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IngestResponse"
                },
                "examples": {
                  "allAccepted": {
                    "summary": "Every point admitted",
                    "value": {
                      "batch_id": "9f2c1a4be6d84f0fa1c3e7b25d908146",
                      "accepted": 3,
                      "rejected": 0
                    }
                  },
                  "partial": {
                    "summary": "One point rejected",
                    "value": {
                      "batch_id": "9f2c1a4be6d84f0fa1c3e7b25d908146",
                      "accepted": 2,
                      "rejected": 1,
                      "errors": [
                        {
                          "field": "points.1.metric",
                          "message": "contains \" \" at position 4; use letters, digits, '_', '.' and '-', starting with a letter or '_'"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "The body could not be parsed, or a header was malformed.",
            "$ref": "#/components/responses/Problem"
          },
          "401": {
            "description": "Missing or invalid credentials.",
            "$ref": "#/components/responses/Unauthorized"
          },
          "409": {
            "description": "The `Idempotency-Key` was already used with a different body.",
            "$ref": "#/components/responses/Problem"
          },
          "413": {
            "description": "The request body exceeded the size limit.",
            "$ref": "#/components/responses/Problem"
          },
          "415": {
            "description": "The `Content-Type` was not `application/json`.",
            "$ref": "#/components/responses/Problem"
          },
          "422": {
            "description": "The batch was structurally valid but semantically unusable: it was\nempty, exceeded the point limit, or every point failed validation.\n",
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "description": "The tenant's quota is exhausted. `Retry-After` says when to try\nagain; its absence means the batch is larger than the burst\nallowance will ever hold and must be split instead.\n",
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "description": "An internal failure; preserve retry identity for ambiguous writes.",
            "$ref": "#/components/responses/Problem"
          },
          "503": {
            "description": "Capacity or a dependency -- the broker, the retry store, or the\nshared rate-limit store -- prevented confirmation. Publication may\nalready have happened. Retry with the same `Idempotency-Key` and\nidentical body; respect `Retry-After` when present.\n",
            "$ref": "#/components/responses/Problem"
          },
          "504": {
            "description": "The request exceeded its processing deadline.",
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/v1/query": {
      "servers": [
        {
          "url": "http://localhost:8082",
          "description": "Local query API; replace with the deployed query URL."
        }
      ],
      "get": {
        "tags": [
          "Query"
        ],
        "operationId": "queryRollups",
        "summary": "Read a metric as time series.",
        "description": "Returns one series per kind and distinct label combination, each with one point\nper window. Points within a series are ordered oldest first, and series\nare ordered stably, so a client diffing two responses does not see them\nshuffle.\n\nResults are always scoped to the tenant owning the credential. There is\nno parameter for selecting a tenant, by design.\n\nThe range is half-open [from, to) on window starts. Matching rows return\nwhole committed window totals, including partial windows and later\ncorrections. This is not filtering individual raw observations. Default\nlimits are 8,784 hours, 500 series and 50,000 points. Series/point limits\nreturn truncated=true; an 8 MiB materialized-read budget returns 422.\n\nWindows older than the deployment's full-resolution retention (30 days\nby default) are kept as hourly totals for a year, so a range reaching\nback that far returns hourly points for its older part. Use a step of\nan hour or more for an even series across both.\n",
        "parameters": [
          {
            "name": "metric",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "http.request.duration_ms"
          },
          {
            "name": "from",
            "in": "query",
            "description": "RFC 3339, or a negative duration relative to `to` such as `-15m`.\nDefaults to one hour before `to`.\n",
            "schema": {
              "type": "string"
            },
            "example": "-15m"
          },
          {
            "name": "to",
            "in": "query",
            "description": "RFC 3339, or a negative duration relative to now. Defaults to now.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "agg",
            "in": "query",
            "description": "Which statistic to read from each window. The percentiles are\nestimated from stored histogram buckets and are only available for\nhistogram metrics; asking for one of a gauge or counter returns an\nempty series and a warning rather than a fabricated zero.\n",
            "schema": {
              "type": "string",
              "default": "avg",
              "enum": [
                "sum",
                "count",
                "avg",
                "min",
                "max",
                "last",
                "p50",
                "p90",
                "p95",
                "p99"
              ]
            }
          },
          {
            "name": "label.*",
            "in": "query",
            "description": "Restricts results to series carrying all the given labels, e.g.\n`label.service=checkout&label.status=500`. The prefix exists so a\nlabel can never collide with this API's own parameters -- a metric\nlabelled `agg` would otherwise be unqueryable.\n",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "step",
            "in": "query",
            "description": "Width of each returned point: a duration such as `5m` or `1h`\n(whole seconds, at most `24h`), or `auto`. Omit it to read stored\nwindows as they are.\n\nStored windows are merged into buckets inside the database: counts\nand sums add, minimum and maximum take the extreme, `last` is the\nvalue with the latest event, and histograms add bucket by bucket,\nso percentiles over a bucket are computed from all of its\nobservations. Buckets are multiples of the step since the Unix\nepoch, so they do not move when a chart pans, and the range is\nwidened outward to whole buckets so neither edge reports a partial\ntotal. `auto` chooses the finest of 1m, 2m, 5m, 10m, 15m, 30m, 1h,\n2h, 3h, 6h, 12h and 24h that keeps a series at or under 720 points.\n\nUse a step that is a multiple of the stored window size (one minute\nby default). Otherwise each window is counted in the bucket\ncontaining its start, and the response carries a warning saying so.\n",
            "schema": {
              "type": "string",
              "examples": [
                "auto",
                "5m",
                "1h"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The matching series.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QueryResult"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "description": "A parameter was invalid or the read exceeded its byte budget. For an oversized result, use a coarser step (step=auto), narrow the time range, or add label filters.",
            "$ref": "#/components/responses/Problem"
          },
          "500": {
            "$ref": "#/components/responses/Problem"
          },
          "503": {
            "description": "Capacity exhausted; respect Retry-After before retrying.",
            "$ref": "#/components/responses/Problem"
          },
          "504": {
            "description": "The query exceeded its processing deadline.",
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/v1/metrics": {
      "servers": [
        {
          "url": "http://localhost:8082",
          "description": "Local query API; replace with the deployed query URL."
        }
      ],
      "get": {
        "tags": [
          "Query"
        ],
        "operationId": "listMetrics",
        "summary": "List the metrics this tenant has data for.",
        "description": "Each entry carries its time range, which saves a caller from probing\nfor it: a UI that has to guess renders an empty chart on its first\nattempt, which reads as \"the system is broken\" rather than \"you asked\nabout the wrong hour\".\n\nEntries group by metric and kind over retained data. There is no\npagination or truncation indicator for this bounded discovery list.\n",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "description": "Defaults to 500 for absent, malformed or nonpositive input; capped at 1000.",
            "schema": {
              "type": "integer",
              "default": 500
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The tenant's metrics.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "metrics": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/MetricSummary"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/Problem"
          },
          "503": {
            "description": "Capacity exhausted; respect Retry-After before retrying.",
            "$ref": "#/components/responses/Problem"
          },
          "504": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/v1/labels": {
      "servers": [
        {
          "url": "http://localhost:8082",
          "description": "Local query API; replace with the deployed query URL."
        }
      ],
      "get": {
        "tags": [
          "Query"
        ],
        "operationId": "listLabels",
        "summary": "List a metric's label keys, or one key's values.",
        "description": "Without `label`, returns the label keys present on the metric. With\n`label`, returns the distinct values that key takes — enough for a UI to\noffer a filter without the caller guessing.\n",
        "parameters": [
          {
            "name": "metric",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "label",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Defaults to 500 for absent, malformed or nonpositive input; keys cap at 500 and values at 1000. No pagination or truncation indicator.",
            "schema": {
              "type": "integer",
              "default": 500
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Label keys, or one label's values.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "metric": {
                      "type": "string"
                    },
                    "labels": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "label": {
                      "type": "string"
                    },
                    "values": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "$ref": "#/components/responses/Problem"
          },
          "500": {
            "$ref": "#/components/responses/Problem"
          },
          "503": {
            "description": "Capacity exhausted; respect Retry-After before retrying.",
            "$ref": "#/components/responses/Problem"
          },
          "504": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/v1/stream": {
      "servers": [
        {
          "url": "http://localhost:8082",
          "description": "Local query API; replace with the deployed query URL."
        }
      ],
      "get": {
        "tags": [
          "Query"
        ],
        "operationId": "streamRollups",
        "summary": "Tail rollups as they are written (server-sent events).",
        "description": "Streams current rollup totals in committed revision order; multiple updates\nbetween polls may coalesce. Each event includes its metric kind. A new\nstream starts from now: it is for watching what happens next, and\nreplaying history on connect would flood a client that only wanted the\nlive edge.\n\n**Resuming.** Every frame that changes the client's position carries an\n`id`: each `rollup` event, a `reset` event, and an id-only frame sent\nimmediately after the `retry` preamble. Reconnect with the most recent\none as `Last-Event-ID` and the stream continues with the next change\nafter it -- nothing skipped, nothing repeated. A row that changed\nagain while the client was away is delivered once, with its current\ntotals. Ids are opaque, tenant-bound and at most 512 characters; treat\nthem as positions, not as data.\n\n**Resets.** When a position cannot be honoured the first event is\n`reset`, with `data` `{\"reason\": ..., \"revision\": ...}`, and the stream\ncontinues live from the latest revision. The client should refetch the\nrange it displays through `GET /v1/query`. Reasons: `stale_cursor`\n(further behind than the server's resume horizon), `future_cursor`\n(ahead of every commit, as after a database restore), `foreign_cursor`\n(issued for another tenant), and `lagging` (a connected stream that\nfell too far behind to catch up). A stream that is behind reads its\nbacklog back to back rather than one page per poll.\n\nServer-sent events rather than WebSocket: the traffic is\none-directional, every HTTP client already speaks it, it survives\nproxies that mangle upgrades, and reconnection is part of the protocol\nrather than of every client.\n\nThe stream advertises a `retry` interval and sends `: keep-alive`\ncomments while idle, so intermediaries do not reap a connection they\nbelieve is dead. Connections are bounded server-side; a client should\nreconnect, which the protocol does automatically.\n\nPer-instance tenant quotas default to eight concurrent streams. Tenant\nquota exhaustion returns 429; instance capacity exhaustion returns 503.\nBoth include Retry-After.\n\nThe cursor advances on committed revision, not event time, so a late\narrival updating a window that closed minutes ago still appears.\n\n**Payloads.** A `rollup` event's `data` is a `StreamRollup` and a\n`reset` event's is a `StreamReset` (see the schemas below).\n\nEvents contain replacement totals, not additive deltas. Default\nconnections last at most 30 minutes, poll every 2 seconds, send\nheartbeats every 20 seconds and honour a resume spanning up to 10,000\ntenant commits. The retry preamble is twice the poll interval.\nHistogram buckets/percentiles are not streamed.\n",
        "parameters": [
          {
            "name": "metric",
            "in": "query",
            "description": "Restricts the tail to one metric. Omit to tail everything.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Last-Event-ID",
            "in": "header",
            "required": false,
            "description": "The id of the last frame received on an earlier connection. The\nstream resumes immediately after it, or begins with a `reset` event\nwhen it cannot. Browsers' EventSource sends it automatically on\nreconnect; other clients should send it themselves. A value this\nserver could not have issued is rejected with 400.\n",
            "schema": {
              "type": "string",
              "maxLength": 512
            }
          }
        ],
        "responses": {
          "200": {
            "description": "An event stream.",
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                },
                "examples": {
                  "live": {
                    "summary": "A new stream",
                    "value": "retry: 4000\n\nid: eyJ2IjoxLCJ0IjoiODVhYjU0N2JlYWQ2NmE4YSIsInIiOjQxfQ\n\nevent: rollup\nid: eyJ2IjoxLCJ0IjoiODVhYjU0N2JlYWQ2NmE4YSIsInIiOjQyLCJrIjoiaGlzdG9ncmFtIiwibSI6ImxpdmUuZGVtbyIsImwiOiJlM2IwYzQ0Mjk4ZmMxYzE0OWFmYmY0Yzg5OTZmYjkyNCIsInciOjE3ODg0ODU3OTAwMDAwMDB9\ndata: {\"kind\":\"histogram\",\"metric\":\"live.demo\",\"labels\":{},\"window_start\":\"2026-09-04T01:36:30Z\",\"window_end\":\"2026-09-04T01:36:40Z\",\"count\":3,\"sum\":600,\"min\":100,\"max\":300,\"last\":300}\n\n: keep-alive\n"
                  },
                  "reset": {
                    "summary": "A resume that could not be honoured",
                    "value": "retry: 4000\n\nevent: reset\nid: eyJ2IjoxLCJ0IjoiODVhYjU0N2JlYWQ2NmE4YSIsInIiOjEyMDQ0fQ\ndata: {\"reason\":\"stale_cursor\",\"revision\":12044}\n"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Last-Event-ID is not a position this stream issued. Reconnect without it.",
            "$ref": "#/components/responses/Problem"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "description": "This tenant has reached its concurrent-stream quota; respect Retry-After.",
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "description": "Failure before the stream starts; after headers, failures may appear as a disconnect or logged failed poll.",
            "$ref": "#/components/responses/Problem"
          },
          "503": {
            "description": "Capacity exhausted; respect Retry-After before retrying.",
            "$ref": "#/components/responses/Problem"
          },
          "504": {
            "description": "Initial database operation exceeded its deadline before stream headers.",
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/healthz": {
      "get": {
        "tags": [
          "Operations"
        ],
        "operationId": "liveness",
        "summary": "Liveness probe.",
        "description": "Reports whether the process is running. Performs no dependency checks\nby design: a database outage should drain an instance, not restart it.\n",
        "security": [],
        "responses": {
          "200": {
            "description": "The process is alive.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProbeStatus"
                }
              }
            }
          }
        }
      }
    },
    "/readyz": {
      "get": {
        "tags": [
          "Operations"
        ],
        "operationId": "readiness",
        "summary": "Readiness probe.",
        "description": "Reports whether this instance should receive traffic.",
        "security": [],
        "responses": {
          "200": {
            "description": "Ready to serve.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProbeStatus"
                }
              }
            }
          },
          "503": {
            "description": "Draining, or a dependency check failed. The `checks` map names the\nfailing dependency.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProbeStatus"
                }
              }
            }
          }
        }
      }
    },
    "/v1/version": {
      "get": {
        "tags": [
          "Operations"
        ],
        "operationId": "version",
        "summary": "Build provenance of the running binary.",
        "security": [],
        "responses": {
          "200": {
            "description": "Build metadata.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VersionInfo"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "An API key in the form `fxg_<key id>_<secret>`, sent as\n`Authorization: Bearer fxg_...`.\n\nThe server stores only a SHA-256 digest of the secret. Every\nauthentication failure returns an identical 401 regardless of cause, so\na probing client cannot use the response to tell a valid key ID from an\ninvalid one.\n"
      }
    },
    "headers": {
      "XRequestId": {
        "description": "Correlation ID, echoed on every response. Quote it when reporting a problem.",
        "schema": {
          "type": "string"
        }
      },
      "XRateLimitLimit": {
        "description": "The sustained allowance in points per second.",
        "schema": {
          "type": "number"
        }
      },
      "XRateLimitRemaining": {
        "description": "Points still available in the burst allowance.",
        "schema": {
          "type": "integer"
        }
      },
      "XRateLimitReset": {
        "description": "Seconds until the allowance is fully replenished.",
        "schema": {
          "type": "integer"
        }
      }
    },
    "responses": {
      "Problem": {
        "description": "An RFC 9457 problem document.",
        "headers": {
          "X-Request-Id": {
            "$ref": "#/components/headers/XRequestId"
          }
        },
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Missing or invalid credentials.",
        "headers": {
          "WWW-Authenticate": {
            "description": "The Bearer challenge.",
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "RateLimited": {
        "description": "Quota exhausted.",
        "headers": {
          "Retry-After": {
            "description": "Seconds to wait before retrying. Absent when retrying cannot help\nbecause the batch exceeds the burst allowance.\n",
            "schema": {
              "type": "integer"
            }
          }
        },
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      }
    },
    "schemas": {
      "QueryResult": {
        "type": "object",
        "required": [
          "metric",
          "aggregation",
          "from",
          "to",
          "series"
        ],
        "properties": {
          "metric": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "gauge",
              "counter",
              "histogram",
              "mixed"
            ]
          },
          "aggregation": {
            "type": "string"
          },
          "from": {
            "type": "string",
            "format": "date-time",
            "description": "The resolved start of the range, so a caller can see what a relative range meant."
          },
          "to": {
            "type": "string",
            "format": "date-time"
          },
          "step": {
            "type": "string",
            "description": "The width of each point when the query merged stored windows,\nincluding the width `step=auto` chose. Absent when stored windows\nwere returned as they are. Points are bucket starts.\n",
            "examples": [
              "2m",
              "1h"
            ]
          },
          "series": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/QuerySeries"
            }
          },
          "truncated": {
            "type": "boolean",
            "description": "True when a limit cut the response short, so a caller can tell an\nincomplete answer from an empty one.\n"
          },
          "warnings": {
            "type": "array",
            "description": "Facts a caller needs that are not errors, such as a percentile\nrequested of a metric that has no histogram.\n",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "QuerySeries": {
        "type": "object",
        "required": [
          "kind",
          "labels",
          "points"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "gauge",
              "counter",
              "histogram"
            ]
          },
          "labels": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "points": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "t",
                "v"
              ],
              "properties": {
                "t": {
                  "type": "string",
                  "format": "date-time",
                  "description": "The window start."
                },
                "v": {
                  "type": "number"
                }
              }
            }
          }
        }
      },
      "StreamRollup": {
        "type": "object",
        "description": "The `data` of a `rollup` event on `GET /v1/stream`: the current totals\nof one series' window, replacing any earlier event for the same\nseries and window. Not an additive delta.\n",
        "required": [
          "kind",
          "metric",
          "labels",
          "window_start",
          "window_end",
          "count",
          "sum",
          "min",
          "max",
          "last"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "gauge",
              "counter",
              "histogram"
            ]
          },
          "metric": {
            "type": "string"
          },
          "labels": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "window_start": {
            "type": "string",
            "format": "date-time"
          },
          "window_end": {
            "type": "string",
            "format": "date-time"
          },
          "count": {
            "type": "integer"
          },
          "sum": {
            "type": "number"
          },
          "min": {
            "type": "number"
          },
          "max": {
            "type": "number"
          },
          "last": {
            "type": "number",
            "description": "The value of the observation with the latest event time."
          }
        }
      },
      "StreamReset": {
        "type": "object",
        "description": "The `data` of a `reset` event on `GET /v1/stream`: the requested\nposition could not be honoured, and the stream continues live from\n`revision`. Refetch the displayed range through `GET /v1/query`.\n",
        "required": [
          "reason",
          "revision"
        ],
        "properties": {
          "reason": {
            "type": "string",
            "enum": [
              "stale_cursor",
              "future_cursor",
              "foreign_cursor",
              "lagging"
            ]
          },
          "revision": {
            "type": "integer",
            "format": "int64"
          }
        }
      },
      "MetricSummary": {
        "type": "object",
        "properties": {
          "metric": {
            "type": "string"
          },
          "kind": {
            "type": "string"
          },
          "series_count": {
            "type": "integer",
            "description": "Distinct label combinations seen for this metric."
          },
          "oldest_window": {
            "type": "string",
            "format": "date-time"
          },
          "newest_window": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "IngestRequest": {
        "type": "object",
        "required": [
          "points"
        ],
        "additionalProperties": false,
        "properties": {
          "points": {
            "type": "array",
            "minItems": 1,
            "maxItems": 1000,
            "items": {
              "$ref": "#/components/schemas/Point"
            }
          }
        }
      },
      "Point": {
        "type": "object",
        "required": [
          "metric",
          "kind",
          "value"
        ],
        "additionalProperties": false,
        "description": "Unknown fields are rejected rather than ignored, so a typo such as\n`timestmap` is reported immediately instead of silently dropping data.\n",
        "properties": {
          "metric": {
            "type": "string",
            "maxLength": 200,
            "pattern": "^[a-zA-Z_][a-zA-Z0-9_.\\-]*$",
            "description": "Dotted metric name. Must start with a letter or underscore; trailing dots and doubled dots are rejected.",
            "example": "http.request.duration_ms"
          },
          "kind": {
            "type": "string",
            "enum": [
              "gauge",
              "counter",
              "histogram"
            ],
            "description": "`gauge` moves in any direction, `counter` is a nonnegative increment (not a cumulative total) and\nmust not be negative, `histogram` is an observation to be bucketed.\n"
          },
          "value": {
            "type": "number",
            "format": "double",
            "minimum": -1e+100,
            "maximum": 1e+100,
            "description": "Required, finite, and at most 1e100 in absolute value. Null is rejected.\nNaN and the infinities are rejected: a single one\npoisons every aggregate it reaches, with nothing left to identify\nwhich point caused it.\n",
            "example": 12.5
          },
          "timestamp": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "RFC 3339. Defaults to the arrival time when omitted or null. May be up to\n5 minutes in the future to tolerate client clock drift, and up to\n7 days in the past by default. Accepted late observations can correct\nan older window; window closure is not a finality guarantee.\n"
          },
          "labels": {
            "type": [
              "object",
              "null"
            ],
            "maxProperties": 20,
            "additionalProperties": {
              "type": "string",
              "maxLength": 256
            },
            "propertyNames": {
              "pattern": "^[a-zA-Z_][a-zA-Z0-9_]*$",
              "maxLength": 64
            },
            "description": "Dimensions to break the metric down by. The 20-label ceiling is the\ntightest limit in the API: cardinality is multiplicative, and an\nunbounded label set is the fastest way to make a time-series store\nunqueryable. Keys beginning `__` are reserved by the platform.\nOmitted or null means an empty label set. Values are limited to\n256 UTF-8 bytes (in addition to the schema character ceiling) and\nmust not contain control characters.\n"
          }
        }
      },
      "IngestResponse": {
        "type": "object",
        "required": [
          "batch_id",
          "accepted",
          "rejected"
        ],
        "properties": {
          "batch_id": {
            "type": "string",
            "description": "Identifies the accepted batch downstream."
          },
          "accepted": {
            "type": "integer",
            "description": "Points admitted to the pipeline."
          },
          "rejected": {
            "type": "integer",
            "description": "Points that failed validation. Always exact."
          },
          "errors": {
            "type": "array",
            "maxItems": 100,
            "description": "The individual failures, capped at 100 entries so a response cannot\ndwarf the request that produced it.\n",
            "items": {
              "$ref": "#/components/schemas/FieldError"
            }
          },
          "errors_truncated": {
            "type": "boolean",
            "description": "True when more than 100 field violations occurred. One rejected point can have several violations, so errors length need not equal rejected."
          }
        }
      },
      "FieldError": {
        "type": "object",
        "required": [
          "field",
          "message"
        ],
        "properties": {
          "field": {
            "type": "string",
            "description": "Dotted path to the offending value, including the batch index.",
            "example": "points.3.labels.service"
          },
          "message": {
            "type": "string",
            "description": "What the submitter must change."
          }
        }
      },
      "Problem": {
        "type": "object",
        "required": [
          "type",
          "title",
          "status",
          "code"
        ],
        "properties": {
          "type": {
            "type": "string",
            "format": "uri"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string",
            "description": "Human-readable explanation. Do not branch on this."
          },
          "code": {
            "type": "string",
            "description": "Stable machine-readable identifier. Branch on this.",
            "enum": [
              "bad_request",
              "validation_failed",
              "unauthorized",
              "forbidden",
              "not_found",
              "method_not_allowed",
              "conflict",
              "payload_too_large",
              "unsupported_media_type",
              "rate_limited",
              "timeout",
              "service_unavailable",
              "internal_error"
            ]
          },
          "request_id": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FieldError"
            }
          }
        }
      },
      "ProbeStatus": {
        "type": "object",
        "required": [
          "status"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "ok",
              "draining",
              "degraded"
            ]
          },
          "checks": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "enum": [
                "ok",
                "unavailable"
              ]
            },
            "description": "Per-dependency result; details of failures are logged server-side, not exposed in this response."
          }
        }
      },
      "VersionInfo": {
        "type": "object",
        "properties": {
          "version": {
            "type": "string"
          },
          "commit": {
            "type": "string"
          },
          "build_date": {
            "type": "string"
          },
          "go_version": {
            "type": "string"
          },
          "platform": {
            "type": "string"
          }
        }
      }
    }
  }
}