# Loki's HTTP API Loki exposes an HTTP API for pushing, querying, and tailing log data. Note that [authenticating](operations/authentication.md) against the API is out of scope for Loki. The HTTP API includes the following endpoints: - [`GET /loki/api/v1/query`](#get-lokiapiv1query) - [`GET /loki/api/v1/query_range`](#get-lokiapiv1query_range) - [`GET /loki/api/v1/label`](#get-lokiapiv1label) - [`GET /loki/api/v1/label//values`](#get-lokiapiv1labelnamevalues) - [`GET /loki/api/v1/tail`](#get-lokiapiv1tail) - [`POST /loki/api/v1/push`](#post-lokiapiv1push) - [`GET /api/prom/tail`](#get-apipromtail) - [`GET /api/prom/query`](#get-apipromquery) - [`GET /ready`](#get-ready) - [`POST /flush`](#post-flush) - [`GET /metrics`](#get-metrics) ## 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) These endpoints are exposed by just the querier: - [`GET /loki/api/v1/query`](#get-lokiapiv1query) - [`GET /loki/api/v1/query_range`](#get-lokiapiv1query_range) - [`GET /loki/api/v1/label`](#get-lokiapiv1label) - [`GET /loki/api/v1/label//values`](#get-lokiapiv1labelnamevalues) - [`GET /loki/api/v1/tail`](#get-lokiapiv1tail) - [`GET /api/prom/tail`](#get-lokiapipromtail) - [`GET /api/prom/query`](#get-apipromquery) 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) 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. [Example clients](#example-clients) can be found at the bottom of this document. ## 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.md) 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. Response: ``` { "status": "success", "data": { "resultType": "vector" | "streams", "result": [] | [] } } ``` Where `` is: ``` { "metric": {