Skip to content

Time syntax

Commands that accept --start and --end (cx logs, cx spans, cx dataprime query, cx metrics query-range) support the following time expressions. cx metrics query uses --time for a single instant instead.

Formats

FormatExampleDescription
nownowCurrent UTC time
Relativenow-1hSubtract a duration from now
Relative with spacesnow - 3dSpaces around - are allowed
ISO 8601 / RFC 33392024-01-01T00:00:00ZAbsolute UTC timestamp

Duration tokens

Relative expressions use humantime duration syntax:
TokenMeaning
sSeconds
mMinutes
hHours
dDays
wWeeks

Compound durations are supported: 1h30m, 2d12h.

Defaults by command

Command--start default--end default
cx logsnow-1hnow
cx spansnow-1hnow
cx dataprime querynow-1hnow
cx metrics query-rangenow-1hnow
cx metrics queryUses --time (defaults to now)N/A

Examples

## Last hour (default)
cx logs 'filter $m.severity == ERROR'

## Last 6 hours
cx logs 'filter $m.severity == ERROR' --start now-6h

## Specific time window
cx logs 'filter $m.severity == ERROR' \
  --start 2024-01-01T00:00:00Z \
  --end 2024-01-01T01:00:00Z

## Last 3 days of spans for a specific service
cx spans 'filter $l.serviceName == "checkout"' --start now-3d