Search Commands
Quick reference Supported in: Self-hosted
Every nPL command, operator and aggregation on one page, with OCSF 1.9 examples.
Use this reference to choose an nPL command and adapt its syntax or example to your search. Fields use OCSF 1.9 paths ; see Syntax for the grammar and Functions for function arguments.
Construct Example Keyword / phrase mimikatz, "access denied"Field compare user.name=administrator, http_response.code>=500, dst_endpoint.port!=443Wildcard process.name=*.ps1, *svchost*Field present / absent user.name=*, user.name!=*Regex process.cmd_line=/-enc\s/, process.cmd_line =~ "-enc", !~IN list class_uid IN (3002, 3003), NOT IN (...)CIDR src_endpoint.ip=10.0.0.0/8, dst_endpoint.ip IN CIDR("10.0.0.0/8", "192.168.0.0/16")Word operators LIKE "%.exe", CONTAINS, STARTSWITH, ENDSWITH (each with NOT)Indicator ioc=203.0.113.50, ioc in [a, b]Subsearch device.hostname IN [search class_uid=3002 status_id=2 | return device.hostname]Boolean AND / &&, OR / ||, NOT, ( )Time earliest=-24h latest=nowComments // to end of line, /* block */
Precedence: in the search expression NOT > OR > AND (a b OR c = a AND (b OR c)); in where and eval NOT > AND > OR.
class_uid=3002 status_id=2 (user.name=administrator OR user.name=root) earliest=-24h // failed admin logons
dst_endpoint.ip IN CIDR("10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16") dst_endpoint.port IN (445, 3389, 5985)
Command Syntax Example search search <expr>svchost | search NOT process.name=svchost.exewhere where <expr>class_uid=4001 | where traffic.bytes_out > 10000000regex regex [f=|f!=]"pat"class_uid=1007 | regex process.cmd_line="-enc\s"dedup , uniqdedup f… [keepfirst=|keeplast=]class_uid=3002 | dedup user.namehead head [N] (10)class_uid=3002 | head 20tail tail [N] (10)class_uid=3002 | tail 5sample sample [N] (1000)class_uid=4002 | sample 50
Command Syntax Example stats stats agg… [by f…]class_uid=3002 | stats count, dc(user.name) by src_endpoint.ipchart chart agg… [over f] [by f]class_uid=4002 | chart count over http_request.http_method by http_response.codetimechart timechart [span=1h] agg… [by f]class_uid=3002 status_id=2 | timechart span=15m counttop top [N] f [by f…]class_uid=4001 | top 10 dst_endpoint.portrare rare [N] f [by f…]class_uid=1007 | rare process.nameeventstats eventstats agg… [by f…]class_uid=4001 | eventstats avg(traffic.bytes_out) as avg_out by src_endpoint.ipstreamstats streamstats [current=] [window=N] agg… [by f…]class_uid=3002 | streamstats count as n by user.namebin , bucketbin f span=<dur|num>class_uid=4001 | bin time span=5m | stats count by timeanomaly anomaly field=f | agg(x) [by f] [threshold=3] [method=zscore|mad]class_uid=4001 | anomaly sum(traffic.bytes_out) by src_endpoint.ip
Command Syntax Example eval eval f=expr[, …]class_uid=4001 | eval total=traffic.bytes_in + traffic.bytes_outtable table f [as a], …class_uid=3002 | table time, user.name, src_endpoint.ipfields fields [+|-] f, …class_uid=1007 | fields - raw_datarename rename f as n, …class_uid=3002 | rename src_endpoint.ip as clientrex , extractrex [field=f] "(?<name>…)", rex mode=sed field=f "s/a/b/g"class_uid=4002 | rex field=http_request.url.path "/api/(?<api>[^/]+)"spath spath [input=f] [output=f] [path=p]see page fillnull fillnull [value=v] f…class_uid=3002 | fillnull value="-" user.domainmvexpand mvexpand f [limit=N]class_uid=4003 | mvexpand answers.rdatasort sort [N] [-|+]f, …… | sort -countreverse reverseclass_uid=3002 | head 20 | reverse
Command Syntax join join [type=inner|left|outer] [max=N] f[, f] [ <subsearch> ]append append [maxout=N] [ <subsearch> ]transaction transaction f… [startswith=…] [endswith=…] [maxspan=dur] [maxevents=N]sequence sequence by f… [maxspan=dur] [cond1] [cond2] …funnel funnel by f… [window=dur] [step1] [step2] …lateral lateral [seed=auto|user|host] [entity=f] [maxhops=N] [window=dur] [methods=auth,network,process]tree tree process, tree web, tree parent=f child=f label=freturn return [N] f, …format format [maxresults=N]
class_uid=1007 | join device.hostname [search class_uid=3002 status_id=2 | stats count as failures by device.hostname | where failures > 50]
class_uid=3002 | sequence by user.name maxspan=10m [status_id=2] [status_id=1]
Command Syntax lookup lookup <table> <col> [AS <event_field>] [OUTPUT|OUTPUTNEW c [AS r], …]inputlookup inputlookup <table> (or url="…")prevalence prevalence enrich=true, prevalence hash_prevalence < 5, prevalence f[, f]resolve_identity , resolve-identityresolve_identity [field=f] [max_age=dur]risk risk score=<0-100|expr> [entity=f] [factor=expr] [weight=0-1]retro ioc=<value> | retro [by asset|host|ip|entity|account|user|indicator]ai ai prompt="…" [max_rows=N]asset asset [field=f]baseline baseline [host=|user=|ip="v"] [window=dur]cloud cloud [by=provider|account|region|service|resource]
output <name> is accepted for compatibility with older saved searches and does nothing.
Use in stats, chart, timechart, eventstats and streamstats. Name a result with as.
Function Meaning count, count(f)Rows, or rows where f is set dc(f) / distinct_count(f), estdc(f)Distinct values (exact / approximate) sum, avg, min, max, rangeNumeric summaries median, mode, stdev, varDistribution percentile(f, N), p95, p99, perc95Percentiles values(f), list(f)Distinct values / all values first, last, earliest, latestValues by order or time sparkline, rate, histogram_quantile(f, N)Trend and OpenTelemetry metric helpers
Conditional form: count(eval(status_id=2)). Expression arguments work: sum(traffic.bytes_in + traffic.bytes_out).
lookup, prevalence, inputlookup, resolve_identity, ai and lateral run after ClickHouse returns rows. After the first of them, only where, head, tail, sort, table, stats, dedup, rename, fields, top, rare, fillnull, eval, timechart, rex, risk, reverse, and tree work.
ai needs nano Self-run with an AI provider configured; on open core every row comes back SKIPPED. See pivt AI settings .
nPL, nano's piped query language: how a query is built, where to start, and every command by task.
nPL search syntax: keywords, field comparisons, wildcards, regex, IN lists, CIDR ranges, ioc terms, precedence, comments, time modifiers and query limits.