Synadia Insights

Search

The search API takes an input string and tries to parse it into a structured form with the semantics defined below. If that fails, it falls back to free-text fuzzy search.

Term Structure

A search term can have up to four components:

[[<entity>@]<attribute>:[<operator>]]<value>
  • value. The only required component. Without a qualifier, the value is treated as a free-text search against a predefined set of string attributes across all applicable entities. Quote a value to allow whitespace. Escape quotes with \".
  • attribute. Qualifies the value against a specific attribute. An attribute can span multiple entities (for example, name matches server, stream, consumer, and so on). Every attribute has a type, and the value is parsed accordingly.
  • operator. An explicit comparison operator for the attribute. Each type has its own set of allowed operators. All operators take a single value except .. (between), which takes two.
  • entity. Fully qualifies the term by binding the attribute to a specific entity type.

Examples

nats-1                           # free-text: matches name, id, cluster, ip, etc.
name:nats-1                      # attribute: name equals "nats-1" (ILIKE) across all entities with name
server@name:nats-1               # entity + attribute: only match servers
rtt:>100ms                       # duration comparison: rtt greater than 100ms
rtt:20ms..40ms                   # range: rtt between 20ms and 40ms (inclusive)
in_bytes:>1gib                   # byte comparison: more than 1 GiB received
name:"With Spaces"               # quoted value with spaces
cpu:>80.5                        # float comparison
is_mirror:true                   # boolean match
NOT slow_consumers:>0            # negation
(name:foo OR name:bar) rtt:<10ms # grouping with implicit AND

Multiple Terms

  • Terms are combined with logical operators: AND, OR, and NOT.
  • Without an explicit operator, adjacent terms are implicitly ANDed.
  • Grouping with parentheses () overrides default precedence.
  • Precedence (lowest to highest): OR < AND < NOT.
  • AND and OR are case-sensitive keywords (must be uppercase).

Value Types

Every attribute has one of the following types. The value in a search term must be parseable as its attribute's type.

string

Plain text. String equality uses case-insensitive matching (ILIKE). Supports =, !=, and ~ (like) operators.

int

Integer number. Supports =, !=, >, >=, <, <=, and .. (between).

float

Floating-point number. Supports the same operators as int.

bool

Boolean value: true or false. Supports = and !=.

duration

A number with a time unit suffix. Stored internally as nanoseconds. Supports the same operators as int.

UnitSuffix
Nanosecondns
Microsecondus, µs
Millisecondms
Seconds
Minutem
Hourh
Dayd

bytes

A number with a byte size unit suffix (IEC binary units, powers of 1024). Supports the same operators as int.

UnitSuffix
Byteb
Kibibytekib
Mebibytemib
Gibibytegib
Tebibytetib

SI suffixes (kb, mb, gb, tb) are not accepted. Use the IEC equivalents above.

timestamp

An ISO-8601 date or datetime value. Supports the same operators as int (for ordering and range comparisons).

Examples: 2024-01-15, 2024-01-15T10:30:00Z

string[]

An array of strings. Matched using the same operators as string. The comparison checks if any element in the array matches.

Example: tags:nats-server matches any entity whose tags array contains an element matching nats-server.

Operators

Not all operators apply to all types. The table below shows which operators are valid for each type.

OperatorSyntaxstringstring[]intfloatdurationbytestimestampbool
Equal(implicit)YYYYYYYY
Not equal!=YYYYYYYY
Greater than>YYYYY
Greater or equal>=YYYYY
Less than<YYYYY
Less or equal<=YYYYY
Between..YYYYY
Like~YY

String equality (=) is case-insensitive (ILIKE). The ~ operator performs an ILIKE substring match.

Entities

There are 13 searchable entity types. Each entity maps to a database view and is scoped to the latest epoch where applicable.

EntityViewEpoch-scoped
serverhx.serversYes
clusterhx.server_identNo
accounthx.account_identNo
userhx.user_identNo
connectionhx.connsYes
streamhx.streamsYes
kvstorehx.streamsYes
objectstorehx.streamsYes
servicehx.servicesYes
consumerhx.consumersYes
leafhx.leafsYes
routehx.routesYes
gatewayhx.gatewaysYes

Attributes

Cross-Entity Attributes

These attributes appear on multiple entities. Using one without an entity qualifier searches all entities that have it.

AttributeTypeserverclusteraccountuserconnectionstreamkvstoreobjectstoreserviceconsumerleafroutegateway
namestringYYYYYYYYY
accountstringYYYYYYY
ipstringYYYYY
clusterstringYYYYY
rttdurationYYYY
in_msgsintYYYY
out_msgsintYYYY
in_bytesbytesYYYY
out_bytesbytesYYYY
num_subsintYYYY
versionstringYYY
descriptionstringYYYY
checkstringYYYYYYYYYYY

The check attribute filters entities by check code (for example, check:SERVER_003). It matches against materialized check results for that entity.

Server Attributes

AttributeType
idstring
hoststring
coresint
portint
start_timetimestamp
tagsstring[]
git_commitstring
go_versionstring
system_accountstring
config_load_timetimestamp
auth_requiredbool
auth_timeoutduration
tls_requiredbool
tls_verifybool
max_payloadbytes
max_pendingbytes
max_control_lineint
max_connectionsint
ping_intervalduration
ping_maxint
write_deadlineduration
http_hoststring
http_portint
https_portint
http_base_pathstring
leaf_hoststring
leaf_portint
leaf_auth_timeoutduration
leaf_tls_timeoutduration
js_domainstring
js_max_memorybytes
js_max_storebytes
js_store_dirstring
js_sync_intervalduration
js_sync_alwaysbool
js_compress_okbool
js_unique_tagstring
memorybytes
cpufloat
connectionsint
subscriptionsint
routesint
leafsint
gatewaysint
js_memorybytes
js_storagebytes
slow_consumersint
ha_assetsint
total_connectionsint
stale_connectionsint
stalled_clientsint
remotesint
js_reserved_memorybytes
js_reserved_storagebytes
js_api_totalint
js_api_errorsint
js_api_inflightint

Cluster Attributes

AttributeType
clusterstring
serversint
cpufloat
memorybytes
connectionsint
ha_assetsint

Cluster attributes (servers, cpu, memory, connections, ha_assets) are computed aggregates.

Account Attributes

AttributeType
is_systembool
jetstream_enabledbool
connsint
subsint
msgs_sentint
msgs_recvint
leafnodesint
slow_consumersint
expiredbool
completebool
num_exportsint
num_importsint
issuer_keystring
labelstring
tagsstring[]
max_subsint
max_databytes
max_payloadbytes
max_connint
max_leaf_connint
max_importsint
max_exportsint
js_mem_storagebytes
js_disk_storagebytes
js_max_streamsint
js_max_consumersint
js_max_ack_pendingint
last_updatetimestamp
total_connsint
bytes_sentbytes
bytes_recvbytes
route_bytes_sentbytes
route_bytes_recvbytes
route_msgs_sentint
route_msgs_recvint
gateway_bytes_sentbytes
gateway_bytes_recvbytes
gateway_msgs_sentint
gateway_msgs_recvint
leaf_bytes_sentbytes
leaf_bytes_recvbytes
leaf_msgs_sentint
leaf_msgs_recvint

User Attributes

AttributeType
accountstring
bearerbool
name_tagstring
connectionsint
issuer_accountstring
tagsstring[]
last_updatetimestamp

Connection Attributes

AttributeType
kindstring
typestring
langstring
tls_versionstring
uptimeduration
idleduration
bytes_sentbytes
bytes_recvbytes
msgs_sentint
msgs_recvint
pending_bytesbytes
idint
portint
tls_cipherstring
mqtt_clientstring
start_timetimestamp
last_activitytimestamp
stop_timetimestamp
reasonstring
stallsint

Stream Attributes

AttributeType
created_attimestamp
storage_typestring
retention_policystring
max_bytesbytes
max_msgsint
max_ageduration
num_replicasint
is_mirrorbool
discard_policystring
sealedbool
subjectsstring[]
placement_clusterstring
placement_tagsstring[]
max_msg_sizebytes
deny_deletebool
deny_purgebool
allow_directbool
max_consumersint
max_msgs_per_subjectint
deduplication_windowduration
config_first_seqint
discard_new_perbool
allow_rollupbool
no_ackbool
consumer_inactive_thresholdduration
consumer_max_ack_pendingint
mirror_namestring
mirror_api_prefixstring
num_sourcesint
store_compressionstring
has_subject_transformbool
has_republishbool
msgsint
bytesbytes
num_subjectsint
num_consumersint
first_seqint
last_seqint
first_tstimestamp
last_tstimestamp
num_deletedint
mirror_lagint
mirror_activeduration
mirror_errorstring

KV Store Attributes

AttributeType
storage_typestring
num_replicasint
keysint
bytesbytes
historyint
ttlduration
max_bytesbytes
sealedbool
deny_deletebool
deny_purgebool
allow_directbool
store_compressionstring
num_consumersint

Object Store Attributes

AttributeType
storage_typestring
num_replicasint
msgsint
bytesbytes
max_bytesbytes
sealedbool
store_compressionstring
num_consumersint

Service Attributes

AttributeType
service_namestring
instancesint
langstring
versionstring
ipstring

Consumer Attributes

AttributeType
streamstring
created_attimestamp
deliver_policystring
ack_policystring
ack_waitduration
max_deliverint
max_ack_pendingint
inactive_thresholdduration
replay_policystring
heartbeatduration
opt_start_seqint
opt_start_timetimestamp
max_waitingint
max_batchint
max_expiresduration
max_bytesbytes
deliver_subjectstring
deliver_groupstring
flow_controlbool
headers_onlybool
num_replicasint
storage_typestring
filter_subjectsstring[]
sample_frequencystring
memory_storagebool
priority_policystring
num_ack_pendingint
num_redeliveredint
num_waitingint
num_pendingint
delivered_stream_seqint
delivered_consumer_seqint
ack_floor_stream_seqint
ack_floor_consumer_seqint
pausedbool
pause_remainingduration
push_boundbool

Leaf Attributes

AttributeType
is_spokebool
compressionstring
idint
portint
is_isolatedbool
subsstring[]

Route Attributes

AttributeType
uptimeduration
idleduration
pending_sizebytes
did_solicitbool
is_configuredbool
compressionstring
start_timetimestamp
last_activitytimestamp
stallsint

Gateway Attributes

AttributeType
uptimeduration
idleduration
pending_sizebytes
is_outboundbool
is_configuredbool
tls_versionstring
tls_cipherstring
authorized_userstring
start_timetimestamp
last_activitytimestamp
stallsint

When a value is provided without an attribute or entity qualifier, it is treated as a free-text search. The value is matched (case-insensitive substring via ILIKE) against these attributes on every entity that has at least one of them:

name, id, cluster, ip, host, version, lang, description, go_version, label, reason, tls_cipher, mqtt_client, js_domain, mirror_name

For example, searching nats-1 checks the name, id, cluster, ip, host, and version columns on the server entity; the name, ip, version, and lang columns on the connection entity; and so on for each entity.

Fuzzy Suggestions

When a search query references an unknown entity or attribute name, the system attempts to suggest corrections instead of returning a generic error.

How It Works

  1. The parsed AST is validated against the registry of known entities and attributes.
  2. Unknown names are compared against valid candidates using Levenshtein distance and prefix matching.
  3. The adaptive threshold is max(1, len(name)/3). Shorter names allow fewer edits.
  4. At most 3 suggestions are returned, sorted by edit distance (closest first).

Examples

servr@name:foo    → "Did you mean: server"    (entity misspelling)
nme:foo           → "Did you mean: name"      (attribute misspelling)
server@nme:foo    → "Did you mean: name"      (scoped attribute misspelling)

Suggestions appear as clickable items in the search dropdown. Clicking a suggestion replaces the query with the corrected version and re-executes the search.

Behavior

  • Suggestions only appear when GenerateQueries fails due to unknown names
  • If no close matches are found, the original error is shown
  • Valid queries produce normal results with no suggestions

Query Semantics

Once parsed into an AST, the search expression is evaluated as follows:

  1. Entity resolution. The parser figures out which entities can satisfy the expression. If a term references a specific entity (for example, server@name:foo), only that entity is queried. If a term references an attribute without an entity, every entity with that attribute is a candidate. Free-text terms match every entity that has at least one free-text attribute. For AND, entity sets are intersected. For OR, they're unioned.

  2. Fan-out. A separate SQL query is generated for each resolved entity. Each query selects the pk and matched columns from the entity's view.

  3. Epoch scoping. For epoch-scoped entities, the query is filtered to the latest epoch (for example, epoch = (SELECT MAX(epoch) FROM hx.server_stats)). That makes sure results reflect the most recent data collection.

  4. Parameterized queries. All user values are passed as parameterized query arguments, not interpolated into SQL.

  5. Result limit. Each entity query is capped at LIMIT 100.

Previous
API