0.1
This page documents the HTTP API available in Ochi 0.1.
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 /insert/loki/ready
Section titled “GET /insert/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 /insert/loki/api/v1/push
Section titled “POST /insert/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 decompressing 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
Error cases
Section titled “Error cases”POST /query
Section titled “POST /query”Query logs by time range plus exact-match tags and fields.
Request headers
Section titled “Request headers”Content-Type: application/json(required when header is set)
Request body
Section titled “Request body”{ "start": 1715173664999999999, "end": 1715173665000000001, "tags": [ { "key": "tag1", "value": "alpha" }, { "key": "tag2", "value": "beta" } ], "fields": [ { "key": "field1", "value": "x" }, { "key": "field2", "value": "x" } ]}Schema:
start: inclusive lower bound, Unix timestamp in nanosecondsend: inclusive upper bound, Unix timestamp in nanosecondstags: array of exact-match tag filtersfields: array of exact-match field filters
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.