Skip to content

API reference

This page documents the HTTP API available in Ochi 0.2.

  • Local default: http://127.0.0.1:9014
  • Multi-tenant routing uses X-Scope-OrgID header.
  • If the header is not provided, Ochi uses tenant default.

Readiness probe endpoint.

Used primarily by Grafana to confirm the datasource availability.

  • Body: none
  • Headers: none required
  • 200 OK
  • Content-Type: text/plain
  • Body: ready

Ingest logs using Loki JSON push format.

Read Loki ingestion API for more details.

  • Content-Type: application/json (required when header is set), only json encoding is supported for payloads
  • Content-Encoding: snappy, only snappy is currently supported for compressed payloads.
{
"streams": [
{
"stream": {
"tag1": "alpha",
"tag2": "beta"
},
"values": [
[
"1715173665000000000", // timestamp in nanoseconds as a string
"same message", // log message
{
"field1": "x",
"field2": "x"
}
]
]
}
]
}

Per log line in values:

  • element 0: timestamp in nanoseconds as a string
  • element 1: log message as a string
  • element 2 (optional): structured metadata object (key -> string value) The JSON object must be a valid JSON object with string keys and string values. The JSON object should not contain any nested object.
  • 200 OK on successful ingestion
  • Empty body

Query logs by time range plus exact-match tags and fields.

Requires a specified header:

  • Content-Type: application/loql
[-15m, now] {tag1=alpha AND tag2=beta} field1=x OR field2=x

Full language reference: LOQL

200 OK with JSON array of matching lines:

[
{
"timestampNs": 1715173665000000000,
"fields": [
{ "key": "tag1", "value": "alpha" },
{ "key": "tag2", "value": "beta" },
{ "key": "field1", "value": "x" },
{ "key": "field2", "value": "x" },
{ "key": "", "value": "same message" }
]
}
]
  • The log message is returned as a field with empty key ("key": "").
  • Query filters are exact matches.

Fetch all the available stream ids.

{
"since": "2h"
"fromNs": 1780225324,
"toNs": 1780225600,
"from": "2025-12-19T16:39:57",
"to": "2025-12-19T16:59:57",
}

The body needs to contain one of the following group of fields, the priorities are kept accordingly:

  • since - duration since what
  • fromNs/toNs - timestamps in nanoseconds to define the time range
  • from/to - timestamps in ISO8601 format to define the time range

200 OK with JSON of matching stream ids:

{
"streamIDs": [1715173665000000, 1715173665000001],
}