--- title: Grafana Loki HTTP API menuTitle: "HTTP API" description: Loki exposes REST endpoints for operating on a Loki cluster. This section details the REST endpoints. aliases: - ../api/ weight: 100 --- # Grafana Loki HTTP API Grafana Loki exposes an HTTP API for pushing, querying, and tailing log data. Note that authenticating 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`](#identify-ready-loki-instance) - [`GET /log_level`](#change-log-level-at-runtime) - [`GET /metrics`](#return-exposed-prometheus-metrics) - [`GET /config`](#list-current-configuration) - [`GET /services`](#list-running-services) - [`GET /loki/api/v1/status/buildinfo`](#list-build-information) - [`GET /loki/api/v1/format_query`](#format-query) These endpoints are exposed by the querier and the query frontend: - [`GET /loki/api/v1/query`](#query-loki) - [`GET /loki/api/v1/query_range`](#query-loki-over-a-range-of-time) - [`GET /loki/api/v1/labels`](#list-labels-within-a-range-of-time) - [`GET /loki/api/v1/label//values`](#list-label-values-within-a-range-of-time) - [`GET /loki/api/v1/series`](#list-series) - [`GET /loki/api/v1/index/stats`](#index-stats) - [`GET /loki/api/v1/tail`](#stream-log-messages) - **Deprecated** [`GET /api/prom/tail`](#get-apipromtail) - **Deprecated** [`GET /api/prom/query`](#get-apipromquery) - **Deprecated** [`GET /api/prom/label`](#get-apipromlabel) - **Deprecated** [`GET /api/prom/label//values`](#get-apipromlabelnamevalues) - **Deprecated** [`GET /api/prom/series`](#list-series) These endpoints are exposed by the distributor: - [`POST /loki/api/v1/push`](#push-log-entries-to-loki) - [`GET /distributor/ring`](#display-distributor-consistent-hash-ring-status) - **Deprecated** [`POST /api/prom/push`](#post-apiprompush) These endpoints are exposed by the ingester: - [`POST /flush`](#flush-in-memory-chunks-to-backing-store) - [`POST /ingester/shutdown`](#flush-in-memory-chunks-and-shut-down) - **Deprecated** [`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) These endpoints are exposed by the compactor: - [`GET /compactor/ring`](#compactor-ring-status) - [`POST /loki/api/v1/delete`](#request-log-deletion) - [`GET /loki/api/v1/delete`](#list-log-deletion-requests) - [`DELETE /loki/api/v1/delete`](#request-cancellation-of-a-delete-request) A [list of clients]({{< relref "../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. ## Timestamp formats The API accepts several formats for timestamps. An integer with ten or fewer digits is interpreted as a Unix timestamp in seconds. More than ten digits are interpreted as a Unix timestamp in nanoseconds. A floating point number is a Unix timestamp with fractions of a second. The timestamps can also be written in `RFC3339` and `RFC3339Nano` format, as supported by Go's [time](https://pkg.go.dev/time) package. ## Query Loki ``` 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]({{< relref "../query" >}}) query to perform - `limit`: The max number of entries to return. It defaults to `100`. Only applies to query types which produce a stream(log lines) response. - `time`: The evaluation time for the query as a nanosecond Unix epoch or another [supported format](#timestamp-formats). 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 format: ``` { "status": "success", "data": { "resultType": "vector" | "streams", "result": [] | [], "stats" : [] } } ``` where `` is: ``` { "metric": {