For the complete documentation index, see llms.txt. This page is also available as Markdown.

Building a Query

Build a Luciq Query API request: choose an entity, select metrics, filter and group results, page through rows, and compare time periods.

The query model

The request body for /v1/query and /v1/query/validate. Every query names an application (application + environment) and an entity; everything else composes the question.

Field
Type
Description

entity (required)

string

What to query. Discover the allowed entities via /v1/entities.

application (required)

string

Your application's slug, as it appears in the dashboard URL (https://dashboard.luciq.ai/applications/<slug>/<environment>/…). Example: react-native-demo-app.

environment (required)

string

App environment, for example production.

select

SelectItem[]

What to compute. Each entry is one of two shapes: a catalog metric {"metric": "apdex", "as": "..."}, or a raw aggregate over a column {"aggregate": "avg", "column": "duration_ms", "as": "..."}. Percentiles are catalog metrics (p50_ms, p95_ms, …) — see each entity in /v1/entities. The two shapes never mix in one entry; as is optional in both.

time_range

TimeRange

Absolute {gte,lte} epoch-ms, or relative {last:"7d"} (window capped at 3 years).

group_by

GroupByItem[]

Dimensions and time buckets: {column} or {time_bucket}.

conditions

ConditionItem[]

Filters: {column, op, value|values}. On app_version, the value may be a relative marker — {"latest": true} or {"top": N}.

having

ConditionItem[]

Post-aggregation filters, same shape as conditions.

order_by

OrderByItem[]

{column, dir:"asc"|"desc"}.

top_n

TopNSpec

{by, dir, n} — n between 1 and 100. Requires group_by with a time_bucket and exactly one column dimension.

limit

integer

Maximum rows to return — defaults to 100, up to the plan's max (see limits). Results over the cap set meta.truncated.

offset

integer

Rows to skip. Needs order_by. See Paging through results.

compare_to

CompareSpec

A second window to compare against. See Top N, comparisons and totals.

include_totals

boolean

Adds a totals block. See Top N, comparisons and totals.

time_zone

string

IANA zone for time bucketing.

Example (daily crash-free sessions in the last 7 days)

curl -s https://api.luciq.ai/v1/query \
  -H "Authorization: Bearer $LUCIQ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "application": "my-application",
  "environment": "production",
  "entity": "sessions",
  "select": [
    {
      "metric": "crash_free_sessions",
      "as": "cfs"
    }
  ],
  "group_by": [
    {
      "time_bucket": "day"
    }
  ],
  "time_range": {
    "last": "7d"
  }
}'

Response is columnar, column names plus row arrays with a meta block carrying query_id and elapsed_ms. It also carries truncated and next_offset when more rows exist, and resolved when relative version markers were used.

A time bucket's column is bucket_ms (bucket start, epoch milliseconds) unless you name it with as.

Paging through results

Results return 100 rows by default. Set limit up to your plan's maximum (see limits in GET /v1/entities).

To page, add order_by and offset. When more rows exist, the response's meta.next_offset is the offset for the next page.

offset + limit can't exceed 50,000 for aggregated results, or 10,000 when listing individual records.

Example: the second page of crash groups in the last 30 days, ordered by count.

Top N, comparisons and totals

Top N. top_n keeps the top N groups. by must be a selected alias. dir defaults to desc. n is at most 100. Top N returns up to n rows per time bucket, so set limit to at least n × buckets.

Grouping networks by endpoint returns two columns: endpoint and endpoint_label. The label is the method and URL pattern, for example POST api.example.com/client/*.

Comparisons. compare_to takes {"period": "previous_period"} or an absolute window {"gte": …, "lte": …}. It adds a <alias>_previous column for each metric. It doesn't work with week or month buckets.

The response columns are bucket_ms, cfs, and cfs_previous.

Totals. include_totals adds a totals block with each metric over the whole window.

compare_to and include_totals can't be combined with top_n.

Reference

Aggregates: count, sum, avg, min, max, uniq

Column types: string, int, float, bool, timestamp, array

Operators: eq, neq, gt, gte, lt, lte, in, not_in, like, ilike. For array columns: has, has_any, has_all, not_has

Time buckets (group_by[].time_bucket): minute, hour, day, week, month. minute works only over short windows; a window too long for the bucket returns 400 with the limit.

Relative ranges (time_range.last): a number plus a unit — m (minutes), h (hours), d (days), w (weeks). Example: {"last": "30d"}. Maximum 3 years.

Last updated