MATIH Platform is in active MVP development. Documentation reflects current implementation status.
8. Platform Services
Logs

Logs

The LogsController and LokiQueryService provide tenant-scoped log querying against the Loki backend. Endpoints support filtering by service, log level, time range, and free-text search. Log queries use LogQL under the hood.


Query Logs (POST)

Endpoint: POST /api/v1/observability/logs

curl -X POST http://localhost:8088/api/v1/observability/logs \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${TOKEN}" \
  -H "X-Tenant-ID: 550e8400" \
  -d '{
    "start": "2026-02-12T09:00:00Z",
    "end": "2026-02-12T10:00:00Z",
    "services": ["ai-service", "query-engine"],
    "levels": ["ERROR", "WARN"],
    "query": "timeout",
    "limit": 500,
    "direction": "backward"
  }'

Query Logs (GET)

Endpoint: GET /api/v1/observability/logs

ParameterTypeDefaultDescription
startInstant1 hour agoStart time
endInstantnowEnd time
servicesListallFilter by service names
levelsListallFilter by log levels
queryStringnullFree-text search
limitint1000Maximum log entries
directionStringbackwardforward or backward

Recent Logs

Endpoint: GET /api/v1/observability/logs/recent

Returns the most recent logs for the tenant (last hour, default 100 entries).

ParameterTypeDefaultDescription
limitint100Maximum entries
servicesListallFilter by services
levelsListallFilter by levels

Error Logs

Endpoint: GET /api/v1/observability/logs/errors

Returns recent ERROR and FATAL level logs.

ParameterTypeDefaultDescription
limitint100Maximum entries
startInstant24 hours agoStart time
endInstantnowEnd time

Available Services

Endpoint: GET /api/v1/observability/logs/services

Returns the list of services that have emitted logs for the tenant within the specified time range.


Available Log Levels

Endpoint: GET /api/v1/observability/logs/levels

Returns the list of standard log levels: TRACE, DEBUG, INFO, WARN, ERROR, FATAL.


LogQueryRequest Structure

FieldTypeDescription
startInstantQuery start time
endInstantQuery end time
servicesListService name filters
levelsListLog level filters
queryStringFree-text search term
limitintMaximum results
directionStringSort direction (forward or backward)

Tenant Scoping

Log queries are automatically scoped to the tenant via the X-Tenant-ID header. The LokiQueryService adds namespace labels to LogQL queries to ensure tenant isolation.