API reference
This page documents the HTTP API available in Ochi 0.2.
Base URL
Section titled “Base URL”- Local default:
http://127.0.0.1:9014
Authentication / tenancy
Section titled “Authentication / tenancy”- Multi-tenant routing uses
X-Scope-OrgIDheader. - If the header is not provided, Ochi uses tenant
default.
GET /ingest/loki/ready
Section titled “GET /ingest/loki/ready”Readiness probe endpoint.
Used primarily by Grafana to confirm the datasource availability.
Request
Section titled “Request”- Body: none
- Headers: none required
Response
Section titled “Response”200 OK- Content-Type: text/plain
- Body:
ready
POST /ingest/loki/api/v1/push
Section titled “POST /ingest/loki/api/v1/push”Ingest logs using Loki JSON push format.
Read Loki ingestion API for more details.
Request headers
Section titled “Request headers”Content-Type: application/json(required when header is set), only json encoding is supported for payloadsContent-Encoding: snappy, onlysnappyis currently supported for compressed payloads.
Request body
Section titled “Request body”{ "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.
Response
Section titled “Response”200 OKon successful ingestion- Empty body
POST /query
Section titled “POST /query”Query logs by time range plus exact-match tags and fields.
Query Language API
Section titled “Query Language API”Requires a specified header:
Content-Type: application/loql
Request body
Section titled “Request body”[-15m, now] {tag1=alpha AND tag2=beta} field1=x OR field2=xFull language reference: LOQL
Response
Section titled “Response”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.
POST /stream_ids
Section titled “POST /stream_ids”Fetch all the available stream ids.
Request body
Section titled “Request body”{ "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
Response
Section titled “Response”200 OK with JSON of matching stream ids:
{ "streamIDs": [1715173665000000, 1715173665000001],}