diff --git a/docs/README.md b/docs/README.md index 82307bac1d..866a449e37 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,42 +1,56 @@ +# Loki Documentation +

Loki Logo
Like Prometheus, but for logs!

-Grafana Loki is a set of components, that can be composed into a fully featured +Grafana Loki is a set of components that can be composed into a fully featured logging stack. -It builds around the idea of treating a single log line as-is. This means that -instead of full-text indexing them, related logs are grouped using the same -labels as in Prometheus. This is much more efficient and scales better. - -## Components -- **[Loki](loki/README.md)**: The main server component is called Loki. It is - responsible for permanently storing the logs it is being shipped and it - executes the LogQL - queries from clients. - Loki shares its high-level architecture with Cortex, a highly scalable - Prometheus backend. -- **[Promtail](promtail/README.md)**: To ship logs to a central place, an - agent is required. Promtail - is deployed to every node that should be monitored and sends the logs to Loki. - It also does important task of pre-processing the log lines, including - attaching labels to them for easier querying. -- *Grafana*: The *Explore* feature of Grafana 6.0+ is the primary place of - contact between a human and Loki. It is used for discovering and analyzing - logs. +Unlike other logging systems, Loki is built around the idea of only indexing +metadata about your logs: labels (just like Prometheus labels). Log data itself +is then compressed and stored in chunks in object stores such as S3 or GCS, or +even locally on the filesystem. A small index and highly compressed chunks +simplifies the operation and significantly lowers the cost of Loki. -Alongside these main components, there are some other ones as well: +## Table of Contents -- **[LogCLI](logcli.md)**: A command line interface to query logs and labels - from Loki -- **[Canary](canary/README.md)**: An audit utility to analyze the log-capturing - performance of Loki. Ingests data into Loki and immediately reads it back to - check for latency and loss. -- **[Docker - Driver](https://github.com/grafana/loki/tree/master/cmd/docker-driver)**: A - Docker [log - driver](https://docs.docker.com/config/containers/logging/configure/) to ship - logs captured by Docker directly to Loki, without the need of an agent. -- **[Fluentd - Plugin](https://github.com/grafana/loki/tree/master/fluentd/fluent-plugin-grafana-loki)**: - An Fluentd [output plugin](https://docs.fluentd.org/output), to use Fluentd - for shipping logs into Loki +1. [Overview](overview/README.md) + 1. [Comparison to other Log Systems](overview/comparisons.md) +2. [Installation](installation/README.md) + 1. [Installing with Tanka](installation/tanka.md) + 2. [Installing with Helm](installation/helm.md) + 3. [Installing Locally](installation/local.md) +3. [Getting Started](getting-started/README.md) + 1. [Grafana](getting-started/grafana.md) + 2. [LogCLI](getting-started/logcli.md) + 4. [Troubleshooting](getting-started/troubleshooting.md) +4. [Configuration](configuration/README.md) + 1. [Examples](configuration/examples.md) +5. [Clients](clients/README.md) + 1. [Promtail](clients/promtail/README.md) + 1. [Installation](clients/promtail/installation.md) + 2. [Configuration](clients/promtail/configuration.md) + 3. [Scraping](clients/promtail/scraping.md) + 4. [Pipelines](clients/promtail/pipelines.md) + 5. [Troubleshooting](clients/promtail/troubleshooting.md) + 2. [Docker Driver](clients/docker-driver/README.md) + 1. [Configuration](clients/docker-driver/configuration.md) + 3. [Fluentd](clients/fluentd.md) +6. [LogQL](logql.md) +7. [Operations](operations/README.md) + 1. [Authentication](operations/authentication.md) + 2. [Observability](operations/observability.md) + 3. [Scalability](operations/scalability.md) + 4. [Storage](operations/storage/README.md) + 1. [Table Manager](operations/storage/table-manager.md) + 2. [Retention](operations/storage/retention.md) + 5. [Multi-tenancy](operations/multi-tenancy.md) + 6. [Loki Canary](operations/loki-canary.md) +8. [HTTP API](api.md) +9. [Architecture](architecture.md) +10. [Community](community/README.md) + 1. [Governance](community/governance.md) + 2. [Getting in Touch](community/getting-in-touch.md) + 3. [Contributing to Loki](community/contributing.md) +11. [Loki Maintainers Guide](./maintaining/README.md) + 1. [Releasing Loki](./maintaining/release.md) diff --git a/docs/api.md b/docs/api.md new file mode 100644 index 0000000000..c0e6193899 --- /dev/null +++ b/docs/api.md @@ -0,0 +1,639 @@ +# 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": { +