Section 3 · Send logs

How the Loki push API accepts log entries

Estimated time: 1 min

Push API for logs

POST /loki/api/v1/push is the endpoint that ingests log entries into Loki, which is the system behind Grafana Cloud Logs.

The default request body is a Snappy-compressed Protocol Buffer message, a compressed binary format, with Content-Type: application/x-protobuf. If you set Content-Type: application/json, you can POST a JSON body instead. That body is a streams array. Each stream has labels and a list of timestamped log lines.

An HTTP client posts log entries to the Loki push API, which stores them in Grafana Cloud Logs

Considerations

  • The API reference includes a curl example that posts one JSON stream.
  • You can gzip the JSON body with Content-Encoding: gzip.
  • You can attach structured metadata to a log line by adding a JSON object of string keys and values after the line text.
  • This is the ingest endpoint in the Loki HTTP API. It is separate from the query API, which is documented for reading Grafana Cloud Logs programmatically.

Documentation