v1

latestOpenAPI 3.0.3Apache 2.02026-07-17333686.7 KB
Query

Execute SPL2 query

Core search endpoint. Executes any SPL2 pipeline including search, aggregation, and management commands.

Execution modes (controlled by wait parameter):

wait valueBehaviorResponse
null (default)Sync. Block up to query.sync_timeout (30s).200 with results, or 202 + job if it exceeds the timeout
0Async. Return immediately.202 with job handle
N (seconds)Hybrid. Wait up to N seconds.200 if done in time, 202 + job otherwise

Hybrid mode (wait: 5) is ideal for Web UI — fast queries return instantly, slow ones degrade to async with progress tracking.

Response data.type determines rendering:

  • events → log viewer (raw events)
  • aggregate → table (stats results)
  • timechart → chart (time-series)
  • view_created → MV creation confirmation (when query contains | materialize)
  • job → async job handle (when wait is set and query didn't complete in time)

MV acceleration: when the query planner detects a Materialized View that covers the query, meta.accelerated_by is present in the response.

SPL2 management commands also flow through this endpoint:

  • | materialize "name" — create MV
  • | from mv_name — read from MV
  • | views — list MVs
  • | dropview "name" — delete MV
post/query

Request body

qstring

SPL2 query string

querystring

Alias for q

earlieststring

Legacy alias for from

lateststring

Legacy alias for to

fromstring

Start time: relative (-1h, -7d) or ISO 8601. Default: -15m

tostring

End time: relative (now, -5m) or ISO 8601. Default: now

limitinteger

Max events to return

offsetinteger

Offset for pagination (tabular results only)

format'json'

Optional response format selector. Only json is accepted on /query.

waitnumber nullable

Controls sync/async behavior:

  • null (default) — Sync. Block until query completes. Returns 200 with results.
  • 0Async. Return 202 immediately with a job handle. Client polls or subscribes to SSE for progress.
  • N (seconds) — Hybrid. Wait up to N seconds. If query completes in time → 200 with results. If not → 202 with job handle and current progress. Best for UI: short queries feel instant, long queries degrade gracefully.
profile'basic' | 'full' | 'trace'

Include richer execution statistics in the response meta.stats.

variablesobject

Template variables substituted into the query before planning.

Example request

{
  "q": "source=nginx status>=500 | stats count by uri",
  "from": "-1h",
  "wait": 5
}

Response

Query completed synchronously. Returned when:

  • wait is null (default sync mode) and query completes in-request
  • wait is N > 0 (hybrid mode) and query completes within N seconds
OR
OR
OR

Example response

{
  "data": {
    "events": [
      {
        "message": "GET /api/users 200 12ms",
        "level": "info",
        "source": "nginx",
        "status": 200
      }
    ]
  },
  "meta": {
    "accelerated_by": {
      "speedup": "~400x"
    }
  }
}