Skip to main content

SRQL Reference

SRQL (ServiceRadar Query Language) is a compact key:value language for querying devices, events, logs, flows, and telemetry. This page is the complete reference: grammar, queryable entities, filterable fields, operators, time syntax, and aggregation.

New to SRQL? Start with the SRQL Tutorial for a guided walkthrough, or jump to the SRQL Cookbook for ready-made recipes.

Overview

SRQL is parsed and executed by the Rust-based SRQL engine (rust/srql). The engine parses the key:value syntax into a query AST, plans it against ServiceRadar's streaming schema, translates it to PostgreSQL via Diesel, and returns consistently shaped JSON results.

Use SRQL to:

  • Select a data domain with in:<entity>.
  • Filter with key:value pairs, wildcards, lists, ranges, and negation.
  • Scope to a time window with time:.
  • Shape results with sort:, limit:, and pagination cursors.
  • Summarize with stats: aggregations or bucket: downsampling.

Query structure

A query is a whitespace-separated list of tokens. Every token is either the in: selector, a reserved keyword (time, sort, limit, stats, etc.), or a key:value filter. Tokens may appear in any order, but every query must include exactly one in: selector.

in:<entity> [key:value ...] [time:<window>] [sort:<field>[:dir]] [limit:<n>] [stats:<expr>]

Example:

in:devices vendor_name:Cisco hostname:%core% time:last_7d sort:last_seen:desc limit:20

Tokenization rules

  • Tokens are separated by whitespace.
  • Wrap values containing spaces in quotes: vendor_name:"Axis Communications". Single quotes, double quotes, and backticks are all accepted.
  • Parentheses ( ) and brackets [ ] group list and range values; whitespace inside them does not split the token.
  • Keys are case-insensitive and lowercased before matching.

The in: selector

in:<entity> chooses which data domain to query. The entity name is case-insensitive, and most entities accept several aliases (for example in:devices and in:device are equivalent).

See Queryable entities for the full list of entities, aliases, and fields.

Operators

SRQL infers the operator from the value you write.

FormOperatorSQL behavior
field:valueequals=
!field:valuenot equals<>
field:%text%containsILIKE (case-insensitive)
!field:%text%does not containNOT ILIKE
field:(a,b,c)one ofIN (...)
!field:(a,b,c)none ofNOT IN (...)
field:>ngreater than>
field:>=ngreater than or equal>=
field:<nless than<
field:<=nless than or equal<=

Notes:

  • Negation applies to the key, written as !key:value. Writing key:!value is not supported.
  • AND is implicit: listing multiple filters means all of them must match.
  • OR for a single field is the list form field:(a,b). There is no general OR keyword across different fields.
  • Ranges are expressed by repeating a numeric field with two comparison bounds: usage_percent:>80 usage_percent:<95.
  • List filters accept at most 200 values.

Wildcards

% is the wildcard character for string matching. It matches any run of characters and emits a case-insensitive ILIKE (or NOT ILIKE when negated).

in:devices hostname:router-% # starts with "router-"
in:devices hostname:%.lab # ends with ".lab"
in:devices hostname:%core% # contains "core"

A value with no % is matched for exact equality.

Time scoping

Use time: (alias timeFrame:) to constrain time-series queries. If you omit a time window, the engine applies a default window.

Relative windows

time:last_<number><unit> — units are m (minutes), h (hours), d (days), and y (years).

in:events time:last_30m
in:logs time:last_24h
in:flows time:last_7d

Shortcuts

in:events time:today
in:events time:yesterday

Absolute ranges

Bracket syntax [start,end] accepts RFC 3339 timestamps. Leave a side blank for an open-ended range.

in:events time:[2026-01-01T00:00:00Z,2026-01-02T00:00:00Z]
in:events time:[2026-01-01T00:00:00Z,] # open end
in:events time:[,2026-01-02T00:00:00Z] # open start

Limits

Most queries are capped at a 90-day time range. Aggregated metric queries (a metric entity combined with stats: or bucket:) may span a longer window because they are served from pre-computed hourly rollups.

Sorting and pagination

  • sort:<field>[:asc|:desc] — orders results. Direction defaults to desc. Multiple sort keys are comma-separated: sort:time:desc,bytes_total. order: is an accepted alias for sort:.
  • limit:<n> — caps the number of rows. Must be a positive integer; the engine enforces a configured maximum.
  • Pagination is cursor-based. Each response includes next_cursor / prev_cursor values that callers pass back to page through results.

Aggregation with stats

stats: collapses rows into summary values.

stats:<function>(<field>) as <alias> [by <field>]
  • Functions: count, sum, avg, min, max.
  • count() takes no field; the others require one.
  • as <alias> names the result column.
  • by <field> groups results (the SQL GROUP BY).
  • Combine multiple aggregations with commas: stats:"count() as total, avg(value) as average".
in:devices stats:count() as total by type
in:cpu_metrics time:last_24h stats:avg(usage_percent) as avg_cpu
in:flows time:last_1h stats:sum(bytes_total) as bytes by src_ip sort:bytes:desc

Downsampling with bucket

For time-series charts, bucket: groups rows into fixed time buckets.

  • bucket:<duration> — bucket width using s|m|h|d suffixes (e.g. bucket:5m).
  • agg:<function> — bucket aggregation: avg (default), min, max, sum, count, or rate (per-second rate of change for counters).
  • series:<field> — splits buckets into one series per distinct value.
  • value_field:<field> — which numeric field to aggregate.
in:timeseries_metrics time:last_7d bucket:5m agg:avg series:metric_name
in:flows time:last_1h bucket:5m agg:sum value_field:bytes_total

Queryable entities

Target data with in:<entity>. Each entity exposes its own set of filterable fields; using a field that the entity does not support returns an unsupported filter field error naming the offending field.

Entity (in:)AliasesDescription
devicesdevice, device_inventoryDevice inventory and current state
eventsactivityNormalized OCSF events and activity
logsApplication and system logs (OpenTelemetry)
flowsflow, network_activityNetFlow / network activity records
servicesserviceObserved services and their availability
gatewaysgatewayGateway/agent operational state
interfacesinterface, discovered_interfacesDiscovered network interfaces (time-series)
bmp_eventsbmp_event, bmp_routing_eventsBGP Monitoring Protocol (BMP) routing events
alertsalertGenerated alerts
cpu_metricscpuCPU utilization time-series
memory_metricsmemoryMemory utilization time-series
disk_metricsdiskDisk utilization time-series
process_metricsprocessesPer-process CPU/memory time-series
timeseries_metricstimeseriesGeneric time-series metrics (incl. SNMP)
snmp_metricssnmpSNMP-collected metrics
rperf_metricsrperfrperf network performance metrics (shares the time-series schema)
otel_metricsmetricsOpenTelemetry span-derived metrics
tracesotel_traces, trace_spansOpenTelemetry trace spans

The engine also exposes specialized entities — device graph (device_graph), device updates (device_updates), Wi-Fi site mapping (wifi_sites, wifi_access_points, …), virtualization (virtualization_hosts, virtualization_guests, …), and field-survey datasets. They use the same key:value grammar described above.

Filterable fields by entity

Each subsection lists the fields you can filter and sort on for that entity. The subsection heading matches the in: name used to select the entity.

devices

FieldAliasesDescription
device_iduidUnique device identifier
hostnameDevice hostname (supports wildcards)
ipIP address — supports wildcards, CIDR (10.0.0.0/8), and ranges (10.0.0.10-10.0.0.50)
macMAC address (normalized; supports wildcards)
gateway_idgatewayAssociated gateway ID
agent_idAssociated agent ID
typedevice_typeDevice type
type_idNumeric device type ID
vendor_namevendorDevice vendor
modelDevice model
risk_levelriskRisk classification
is_availableavailableCurrently reachable (true/false)
is_activeactiveLifecycle state (true/false)
discovery_sourcesSources that discovered the device (array; list form)
tagsDevice tags (array; list form). Sub-key form: tags.<key>:<value>
metadata.<key>Match an arbitrary metadata key, e.g. metadata.integration_type:armis

Sortable fields include hostname, ip, first_seen / first_seen_time, last_seen / last_seen_time, and type_id.

Control tokens: include_inactive:true returns devices regardless of lifecycle state; include_deleted:true includes soft-deleted records.

events

FieldAliasesDescription
idEvent identifier
device_iduid, source_device_uidAssociated device
class_uidOCSF class UID
category_uidOCSF category UID
type_uidOCSF type UID
activity_idActivity ID
activity_nameActivity name
severity_idNumeric severity ID
severitySeverity label
messageshort_messageEvent message
log_nameLog name or subject
log_providerLog provider
log_levelLog level
statusStatus label
status_idNumeric status ID
status_codeStatus code
status_detailStatus detail
trace_idOpenTelemetry trace ID
span_idOpenTelemetry span ID

Sortable fields: time (aliases event_timestamp, timestamp).

logs

FieldAliasesDescription
idLog record identifier
device_iduid, source_device_uidAssociated device
gateway_idAssociated gateway ID
agent_idAssociated agent ID
trace_idOpenTelemetry trace ID
span_idOpenTelemetry span ID
service_nameserviceEmitting service
service_versionService version
service_instanceService instance identifier
sourceLog source
scope_nameInstrumentation scope name
scope_versionInstrumentation scope version
severity_textseverity, levelSeverity text (e.g. error, warn)
severity_numberNumeric severity
bodymessageLog message body

Sortable fields: timestamp, severity_number.

flows

FieldAliasesDescription
device_idAssociated device
src_endpoint_ipsrc_ipSource IP (supports wildcards)
dst_endpoint_ipdst_ipDestination IP (supports wildcards)
src_cidrSource CIDR containment match
dst_cidrDestination CIDR containment match
src_endpoint_portsrc_portSource port
dst_endpoint_portdst_portDestination port
protocol_nameProtocol name
protocol_numprotoProtocol number
protocol_groupproto_groupProtocol group
directionFlow direction
flow_sourcecollectorOriginating collector
appDerived application classification label
sampler_addressFlow exporter / sampler address
exporter_nameResolved exporter name
in_if_nameIngress interface name
out_if_nameEgress interface name
in_if_speed_bpsIngress interface speed (bps)
out_if_speed_bpsEgress interface speed (bps)

Sortable fields: time, bytes_total, packets_total, bytes_in, bytes_out, packets_in, packets_out.

services

FieldAliasesDescription
service_namenameService name
service_iduidService identifier
service_typetypeService type
gateway_idAssociated gateway ID
agent_idAssociated agent ID
partitionPartition identifier
messageStatus message
availableAvailability (true/false)

Sortable fields: timestamp / last_seen, service_name / name, service_type / type.

gateways

FieldDescription
gateway_idGateway identifier
statusGateway status
component_idComponent identifier
registration_sourceRegistration source
spiffe_identitySPIFFE identity
created_byCreator identifier
is_healthyHealth status (true/false)

Sortable fields: last_seen, first_seen, first_registered, gateway_id, status, agent_count, checker_count, updated_at.

interfaces

Interface observations are stored as time-series data. Use latest:true to return the most recent record per interface.

FieldAliasesDescription
device_idDevice identifier
device_ipipDevice IP address
interface_uidStable interface identifier (per device)
gateway_idAssociated gateway ID
agent_idAssociated agent ID
if_nameInterface name
if_descrdescriptionInterface description
if_aliasInterface alias
if_indexInterface index (ifIndex)
if_typeInterface type identifier (ifType)
if_type_nameInterface type (human-readable)
interface_kindClassification (physical, virtual, loopback, tunnel, …)
if_phys_addressmacPhysical (MAC) address
if_admin_statusadmin_statusAdministrative status
if_oper_statusoper_status, statusOperational status
if_speedspeed, speed_bpsInterface speed
mtuInterface MTU
duplexInterface duplex
ip_addressesip_addressIP addresses assigned to the interface (list form)

Sortable fields: timestamp, device_ip, device_id, interface_uid, if_name, if_descr, if_index, if_type, if_type_name, interface_kind, speed_bps, mtu.

bmp_events

in:bmp_events is how you query BGP routing data — peer events and prefix advertisements collected via the BGP Monitoring Protocol (BMP).

FieldDescription
idEvent identifier
event_typeBMP event type
router_idReporting router ID
router_ipReporting router IP
peer_ipBGP peer IP
peer_asnBGP peer ASN (numeric)
local_asnLocal ASN (numeric)
prefixAdvertised/withdrawn prefix
messageEvent message
raw_dataRaw event payload
severity_idNumeric severity ID

Sortable fields: time (aliases event_timestamp, timestamp), created_at, severity_id.

alerts

FieldDescription
idAlert identifier
titleAlert title
descriptionAlert description
severityAlert severity
statusAlert status
source_typeSource type
source_idSource identifier
device_uidAssociated device
agent_uidAssociated agent
metric_nameMetric that triggered the alert
comparisonComparison operator used
acknowledged_byWho acknowledged the alert
resolved_byWho resolved the alert
escalation_reasonEscalation reason

Sortable fields: triggered_at / timestamp, severity, status, title.

cpu_metrics

FieldDescription
gateway_idAssociated gateway ID
agent_idAssociated agent ID
host_idHost identifier
device_idDevice identifier
partitionPartition identifier
clusterCluster name
labelLabel
core_idCPU core identifier
usage_percentCPU usage percentage
frequency_hzCPU frequency in Hz

Sortable fields: timestamp, usage_percent, gateway_id, device_id, host_id, partition, core_id.

memory_metrics

FieldDescription
gateway_idAssociated gateway ID
agent_idAssociated agent ID
host_idHost identifier
device_idDevice identifier
partitionPartition identifier
usage_percentMemory usage percentage
total_bytesTotal memory in bytes
used_bytesUsed memory in bytes
available_bytesAvailable memory in bytes

Sortable fields: timestamp, usage_percent, gateway_id, device_id, host_id.

disk_metrics

FieldDescription
gateway_idAssociated gateway ID
agent_idAssociated agent ID
host_idHost identifier
device_idDevice identifier
partitionPartition identifier
mount_pointFilesystem mount point
device_nameDevice name
usage_percentDisk usage percentage
total_bytesTotal disk space in bytes
used_bytesUsed disk space in bytes
available_bytesAvailable disk space in bytes

Sortable fields: timestamp, usage_percent, gateway_id, device_id, host_id, mount_point.

process_metrics

FieldDescription
gateway_idAssociated gateway ID
agent_idAssociated agent ID
host_idHost identifier
device_idDevice identifier
partitionPartition identifier
pidProcess ID
nameProcess name
statusProcess status
start_timeProcess start time
cpu_usageProcess CPU usage
memory_usageProcess memory usage

Sortable fields: timestamp, cpu_usage, memory_usage, pid, name.

timeseries_metrics

in:timeseries_metrics (and the snmp_metrics / rperf aliases that share this schema) cover generic time-series data, including SNMP counters.

FieldDescription
gateway_idAssociated gateway ID
agent_idAssociated agent ID
metric_nameName of the metric
metric_typeType of metric
device_idDevice identifier
target_device_ipTarget device IP address
partitionPartition identifier
if_indexInterface index
valueMetric value

Sortable fields: timestamp, gateway_id, metric_name, metric_type, device_id, value.

otel_metrics

FieldAliasesDescription
trace_idOpenTelemetry trace ID
span_idSpan identifier
service_nameserviceEmitting service
span_nameSpan name
span_kindSpan kind
metric_typetypeMetric type
componentComponent name
levelLevel
http_methodHTTP method
http_routeHTTP route
http_status_codeHTTP status code
grpc_servicegRPC service name
grpc_methodgRPC method name
grpc_status_codegRPC status code
is_slowSlow-request flag (true/false)

Sortable fields: timestamp, service_name / service, metric_type / type.

traces

FieldAliasesDescription
trace_idOpenTelemetry trace ID
span_idSpan identifier
parent_span_idParent span identifier
service_nameEmitting service
service_versionService version
service_instanceService instance identifier
scope_nameInstrumentation scope name
scope_versionInstrumentation scope version
namespan_nameSpan name
status_messageStatus message
status_codeNumeric status code
kindspan_kindSpan kind (integer)

Sortable fields: timestamp, start_time_unix_nano, end_time_unix_nano, service_name.

Error handling

MessageCause / fix
queries must include an in:<entity> tokenAdd an in:<entity> selector.
unsupported entity '<x>'The entity name is not recognized. See Queryable entities.
unsupported filter fieldThe field is not valid for the chosen entity. Check Filterable fields by entity.
unsupported time token / invalid time literalThe time: value is malformed. Use last_<n><unit>, today/yesterday, or [start,end].
time range cannot exceed 90 daysNarrow the window, or use a metric entity with stats:/bucket: for longer ranges.
invalid limit / limit must be a positive integerlimit: requires a positive integer.
expected scalar value / expected list valueOperator/value mismatch — e.g. a list value where a scalar is expected.

See also