--- title: HTTP API weight: 900 --- # Loki HTTP API Loki exposes an HTTP API for pushing, querying, and tailing log data. Note that [authenticating](../operations/authentication/) against the API is out of scope for Loki. ## Microservices mode When deploying Loki in microservices mode, the set of endpoints exposed by each component is different. These endpoints are exposed by all components: - [`GET /ready`](#get-ready) - [`GET /metrics`](#get-metrics) - [`GET /config`](#get-config) - [`GET /loki/api/v1/status/buildinfo`](#get-lokiapiv1statusbuildinfo) These endpoints are exposed by the querier and the frontend: - [Loki's HTTP API](#lokis-http-api) - [Microservices Mode](#microservices-mode) - [Matrix, Vector, And Streams](#matrix-vector-and-streams) - [`GET /loki/api/v1/query`](#get-lokiapiv1query) - [Examples](#examples) - [`GET /loki/api/v1/query_range`](#get-lokiapiv1query_range) - [Step vs Interval](#step-vs-interval) - [Examples](#examples-1) - [`GET /loki/api/v1/labels`](#get-lokiapiv1labels) - [Examples](#examples-2) - [`GET /loki/api/v1/label//values`](#get-lokiapiv1labelnamevalues) - [Examples](#examples-3) - [`GET /loki/api/v1/tail`](#get-lokiapiv1tail) - [`POST /loki/api/v1/push`](#post-lokiapiv1push) - [Examples](#examples-4) - [`GET /api/prom/tail`](#get-apipromtail) - [`GET /api/prom/query`](#get-apipromquery) - [Examples](#examples-5) - [`GET /api/prom/label`](#get-apipromlabel) - [Examples](#examples-6) - [`GET /api/prom/label//values`](#get-apipromlabelnamevalues) - [Examples](#examples-7) - [`POST /api/prom/push`](#post-apiprompush) - [Examples](#examples-8) - [`GET /ready`](#get-ready) - [`GET /metrics`](#get-metrics) - [Series](#series) - [Examples](#examples-9) - [Statistics](#statistics) While these endpoints are exposed by just the distributor: - [`POST /loki/api/v1/push`](#post-lokiapiv1push) And these endpoints are exposed by just the ingester: - [`POST /flush`](#post-flush) - [`POST /ingester/flush_shutdown`](#post-ingesterflush_shutdown) The API endpoints starting with `/loki/` are [Prometheus API-compatible](https://prometheus.io/docs/prometheus/latest/querying/api/) and the result formats can be used interchangeably. These endpoints are exposed by the ruler: - [`GET /ruler/ring`](#ruler-ring-status) - [`GET /loki/api/v1/rules`](#list-rule-groups) - [`GET /loki/api/v1/rules/{namespace}`](#get-rule-groups-by-namespace) - [`GET /loki/api/v1/rules/{namespace}/{groupName}`](#get-rule-group) - [`POST /loki/api/v1/rules/{namespace}`](#set-rule-group) - [`DELETE /loki/api/v1/rules/{namespace}/{groupName}`](#delete-rule-group) - [`DELETE /loki/api/v1/rules/{namespace}`](#delete-namespace) - [`GET /api/prom/rules`](#list-rule-groups) - [`GET /api/prom/rules/{namespace}`](#get-rule-groups-by-namespace) - [`GET /api/prom/rules/{namespace}/{groupName}`](#get-rule-group) - [`POST /api/prom/rules/{namespace}`](#set-rule-group) - [`DELETE /api/prom/rules/{namespace}/{groupName}`](#delete-rule-group) - [`DELETE /api/prom/rules/{namespace}`](#delete-namespace) - [`GET /prometheus/api/v1/rules`](#list-rules) - [`GET /prometheus/api/v1/alerts`](#list-alerts) A [list of clients](../clients) can be found in the clients documentation. ## Matrix, vector, and streams Some Loki API endpoints return a result of a matrix, a vector, or a stream: - Matrix: a table of values where each row represents a different label set and the columns are each sample value for that row over the queried time. Matrix types are only returned when running a query that computes some value. - Instant Vector: denoted in the type as just `vector`, an Instant Vector represents the latest value of a calculation for a given labelset. Instant Vectors are only returned when doing a query against a single point in time. - Stream: a Stream is a set of all values (logs) for a given label set over the queried time range. Streams are the only type that will result in log lines being returned. ## `GET /loki/api/v1/query` `/loki/api/v1/query` allows for doing queries against a single point in time. The URL query parameters support the following values: - `query`: The [LogQL](../logql/) query to perform - `limit`: The max number of entries to return - `time`: The evaluation time for the query as a nanosecond Unix epoch. Defaults to now. - `direction`: Determines the sort order of logs. Supported values are `forward` or `backward`. Defaults to `backward.` In microservices mode, `/loki/api/v1/query` is exposed by the querier and the frontend. Response: ``` { "status": "success", "data": { "resultType": "vector" | "streams", "result": [] | []. "stats" : [] } } ``` Where `` is: ``` { "metric": {