Skip to Content
KubeSense

Filter quick reference

How to filter logs, traces, events, user sessions, alerts, SLOs, dashboards and log pipelines with filters, with an example for every kind of filter.

This page shows how to filter your data in KubeSense with filters, with an example for every kind of filter. It also holds the syntax rules that every screen shares.

What is a filter

A filter is a line of text. You write field:value, such as workload:payment, and join terms with a space, AND, OR and brackets. Every filter bar uses it, so the same text finds the same rows on every screen that reads stored data. Log pipelines run before a log is stored and differ in three cases. A few screens accept only part of the language. Filtering on each screen lists them.

The Logs page filtered with workload:(cart OR quote). The Workload filter ticks cart and quote to match the text.

The filter bar replaces the chips of Basic and the SQL-like text of Advanced. A saved filter opens in the filter bar, and KubeSense checks that it finds the same rows. Nothing in storage changes until you save it. If KubeSense cannot prove it finds the same rows, the filter opens as it was and the screen says why. If the meaning had to change, a notice says so.

info: There is no separate filter tab. The Basic tab is the filter bar, and new filter bars open in it. Advanced stays beside it for now. Later it becomes read-only, and then it is removed.

Start here

These six filters cover most searches. Each one runs on the Logs page.

WriteWhat it finds
workload:paymentEverything from the payment workload.
type:ERROR workload:paymentErrors from payment. A space means both must match.
type:(ERROR OR WARN)Errors or warnings.
-workload:paymentEverything except payment.
workload:pay*Workloads whose name starts with pay.
body:timeoutLog lines that contain the word timeout.

On the Traces page, service:checkout duration_ms>500 finds spans of the checkout service that took more than 500 milliseconds.

service:checkout duration_ms>500

Reference

Examples run on the Logs page unless a heading names another screen. Field names are the filter names in Log and trace fields, which differ from SQL column names in a few places.

Terms and operators

To matchWriteWhat it matches
A valueworkload:paymentworkload is exactly payment. Case matters.
Anything but a value-workload:payment or NOT workload:paymentworkload is not payment.
Both termstype:ERROR workload:paymentA space means AND.
Both terms, written outtype:ERROR AND workload:paymentThe same rows.
Either termtype:ERROR OR type:WARNAt least one term matches.
A group(type:ERROR OR type:WARN) workload:paymentBrackets set the order.
Any of several valuesworkload:(payment OR cart)workload is payment or cart.
None of several values-workload:(payment OR cart)workload is neither.
All of several patternsworkload:(*pay* *api*)workload contains pay and api. A space in the brackets means AND.

AND, OR and NOT must be capitals. In lowercase they are ordinary words, except that or and and between the values of a list are an error: write OR in capitals, or quote the word, as in workload:(a OR "or"). Without brackets, AND binds before OR, so type:ERROR OR type:WARN workload:payment means type:ERROR OR (type:WARN workload:payment).

A list in brackets takes OR or AND, not both. A space between values is AND, as it is between terms, so body:(payment failed) needs both words. A field such as workload holds one value per row, so workload:(payment cart) finds nothing. Write workload:(payment OR cart) for either, or use AND with patterns, as in workload:(*pay* *api*). The audit, issues, anomaly, workloads, Kubernetes, host and cloud lists take OR only.

Wildcards and case

To matchWriteWhat it matches
Any run of charactersworkload:pay*payment, payments, pay. The * can sit anywhere.
One characterworkload:pay?mentpayxment.
A part of a valueworkload:*pay*Contains pay.
Ignore letter caseworkload:~Paymentpayment, PAYMENT, Payment.
Wildcard, ignore caseworkload:~pay*Payment-api, PAY-gateway.

Put ~ directly after the colon. A pattern matches the whole value, so workload:pay* does not match my-payment. Use workload:*pay* for that.

Some fields take only exact values, such as error_message on RUM errors and every field on the workloads, audit, issues and anomaly lists. filter names the field when you try a wildcard or ~.

Comparisons

To matchWriteWhat it matches
More thanduration_ms>100More than 100 milliseconds.
At leastduration_ms>=100100 milliseconds or more.
Less than, at mostduration_ms<500, duration_ms<=500Below 500, or 500 and below.
A rangeduration_ms>=100 duration_ms<500100 to 499 milliseconds.

Comparisons work on numeric fields and on any @attribute. duration_ms takes a plain number of milliseconds, so duration_ms>100ms and duration_ms>1e3 are errors. A text field such as status_code refuses >=. Write status_code:5* for all 5xx codes.

A value such as a URL path needs no quotes. It runs until a space or one of ( ) : " < > ~ =.

resource:/api/v1/users

Attributes

Attributes are the key and value pairs your instrumentation emits, such as http.route or user.id. Start the name with @. Every operator above works on them.

To matchWriteWhat it matches
An attribute value@http.route:/checkouthttp.route is /checkout.
A number@http.status_code>=500500 or more. The attribute can hold a number or text that reads as one.
A key with spaces or symbols@"my key":xQuote the key.
A list element@items[0]:xThe first element. Logs only.
Any list element@items[*]:xAt least one element is x. Logs only. See Lists in a log.
The key exists@user.id:*Has a user.id attribute.
The key is missing-@user.id:*Has no user.id attribute.

note: -@key:value differs between screens. On logs and events it matches rows that have the key with a different value. On traces and RUM it also matches rows that have no such key. To require the key on traces, write @http.route:* -@http.route:/checkout.

Lists in a log

@tags:x reads the attribute named tags as one value. @tags[*]:x looks inside the list tags in the parsed log and matches when any element matches. Logs only. @tags[0] reads one element by position.

To matchWriteWhat it matches
An element@tags[*]:prodAt least one element is prod.
A pattern, ignoring case@tags[*]:~prod*An element such as Prod-eu.
One of several@tags[*]:(a OR b)An element is a, or an element is b.
No element-@tags[*]:prodThe list has no element prod.
The list exists@tags[*]:*The log has a tags list.
A number@scores[*]>5An element is over 5. Elements are read as numbers.

[*] must end the key. @a[*].b, @a[*][0] and @a[0][*] are errors. On traces, RUM and events [*] is an error, because only logs have a parsed log. A /regex/ on [*] is refused.

Has a value

field:* matches rows where the field has a value. On a column, that means the value is not empty.

workload:*
@user.id:*

In a log pipeline, type:/^/ and body:/^/ mean the event has that value, empty or not. See log pipelines.

A converted filter that used exist(...) can behave differently from a new one. See An exist check on a column.

Quotes and escapes

A value with a space or one of ( ) : " < > ~ = needs quotes. Inside quotes, write \" for a quote and \\ for a backslash. Write \* or \? for a literal star or question mark, quoted or not. A value that is AND, OR or NOT also needs quotes.

workload:"my service"
workload:"say \"hi\""
body:"50% done"
workload:a\*b

Searching the log body

body is the log message. It is the only field with word search, and it ignores letter case.

To matchWriteWhat it matches
A wordbody:timeoutThe whole word timeout, in any case. Not timeouts.
A phrasebody:"payment failed"The two words together, in that order, in any case.
Any of several wordsbody:(timeout OR refused)Either word.
Any of several partsbody:(*time* OR *refus*)Either text anywhere.
All of several wordsbody:(connection reset) or body:(connection AND reset)Both words.
A part of a wordbody:*time*The text time anywhere, as in timeout and sometimes.
Lines without a word-body:errorNo word error.

How KubeSense reads a body value:

  • A word of two or more letters and digits is a whole-word search.
  • A value with separators, such as node-agent, 16.1.1 or "payment failed", is a phrase: the line must contain exactly that text, in any case. "16.1.1" finds version 16.1.1, not a line that only has 16.
  • A value with * is a pattern over the whole line. body:time* matches only lines that start with time.
  • A value with ? is a pattern over the whole line too, where ? is one character. body:er?or matches a line that is only error. Write body:*er?or* to find it inside a line.
  • Text with no word in it, such as body:a, body:. or body:->, is found anywhere in the line.
  • Letters outside A to Z, such as é in body:café, ignore case too: café also finds CAFÉ.

On the Logs page, the words and the text your query searches for in body are highlighted in the log lines. A negated term, such as -body:error, highlights nothing.

Other fields have no word search. To find a word inside a value, write workload:~*payment*.

Words without a field

On logs, a word or a quoted phrase with no field searches the log message. It works on the Logs page, in alerts, dashboards and log pipelines, and follows every body rule above.

To matchWriteSame as
A wordtimeoutbody:timeout
Several words"payment failed"body:"payment failed"
Lines without a word-timeout or NOT timeout-body:timeout
Either word(timeout OR refused)(body:timeout OR body:refused)
A part of a word*time*body:*time*
A word that starts a linepay*body:pay*
The character @@body:"@"
A word and a fieldworkload:payment timeoutworkload:payment body:timeout
Errors without a wordtype:ERROR AND -timeouttype:ERROR AND -body:timeout

@ on its own is text. @level is not: it names an attribute and needs a value, as in @level:error. To search for that text, write "@level".

AND, OR and NOT in capitals stay operators. To search for one of them, write body:"OR".

Only logs have a message to search. On traces, events and RUM, a word on its own is an error. Add a field.

checkout

Variables on dashboards

A dashboard variable is a drop-down whose current choice a panel query can read. Write $name where the variable is the whole value. Write ${name} where it is part of a value, such as a prefix or a substring.

Suppose env has payment and checkout selected. The workloads are payment, Payment, payment-service, repayments, checkout, checkout-api, payment-api and my-Payment-api. The table shows how KubeSense reads each form.

WriteRead asMatches
workload:$envworkload:(payment OR checkout)payment, checkout. Exact values, so Payment does not match.
workload:${env}The same as workload:$envThe same rows.
workload:~$envworkload:(~payment OR ~checkout)payment, Payment, checkout. Ignores letter case.
workload:${env}*workload:(payment* OR checkout*)payment, payment-service, payment-api, checkout, checkout-api.
workload:~*${env}*workload:(~*payment* OR ~*checkout*)All eight. Each contains payment or checkout, in any case.
workload:${env}-apiworkload:(payment-api OR checkout-api)payment-api, checkout-api.
$$envworkload:(payment OR checkout)The same rows, when env lists workload.
workload:*$env*Left as writtenA workload whose name contains the text $env. None here.
workload:"$env"Left as writtenA workload named exactly $env. None here.

How a variable behaves:

  • The field too. $$name on its own is the variable's field with its selected values, so type:ERROR $$svc is type:ERROR workload:$svc when svc lists workload. See Referencing a variable's field.
  • Several values. ${name} makes one pattern per selected value and joins them with OR, as in the table.
  • No value selected. The term is dropped, so type:ERROR workload:${svc}* becomes type:ERROR. A negated term is dropped too.
  • Values are literal. A * or ? in a selected value is not a wildcard, and a value cannot add a condition.
  • Several variables in one term. workload:${svc}-${env} tries every combination of the selections, up to 500. A selection that would make more is an error.
  • Case. ~${name} and ~$name ignore letter case.
  • Not a variable. A $ inside a larger term, such as *$env* or $env-api, and a quoted "$env" are plain text. Write ${env} to use the variable.
  • Where it works. Only on a dashboard. Anywhere else, a $name, ${name} or $$name is ordinary text, searched as typed: service:$nope is the same as service:"$nope". A bare $$nope on logs is a word search on the body. On traces, events and RUM a bare word is an error, as any bare word is, and $$nope:x is an unknown field.
  • A variable that does not exist. On a dashboard, a term that names a variable the dashboard does not have is ignored, in every form: $name, $$name and ${name}. type:ERROR workload:$gone runs as type:ERROR. A filter converted from Basic or Advanced that names a missing variable is handled the same way. See A variable the dashboard does not have, ignored.
  • Comparisons. A variable cannot sit in a comparison. duration_ms>${x} is an error.

Dashboards and variables covers the dashboard side.

duration_ms>${x}

Regular expressions

A /regex/ term works only in log pipeline conditions and in log-to-metric filters. Everywhere else it is an error, because the other screens have no regular-expression search.

body:/payment .* failed/
workload:/^pay-/
body:/payment .* failed/

In a pipeline, a regular expression is case-sensitive and matches anywhere in the value. Back-references and look-around are refused. To keep case on body in a pipeline, write body:/Payment/. See log pipelines and log-to-metric.

Versions

The filter syntax has a version. Version 1 is today's grammar and the latest. A filter with no version runs at the latest.

  • KubeSense stores the version with every saved filter text. A filter you have not touched keeps its version. When you edit one, it saves at the latest.
  • A new version is made only when a change would alter what existing text matches. Older versions stay readable, text that is proved to match the same rows is migrated to the new version, and a notice announces any deprecation before it happens.
For API and Terraform users

Any filter text (sent as kql) can carry an optional integer kql_version beside it. Leave it out to use the latest, and send it only to pin a version. A value outside the supported range returns 400 bad_kql_version, naming the range. Reads return the version, and the validate endpoint returns version and latest_version. MCP tools that take a filter accept an optional kql_version too.

Limits

  • A filter text can be at most 16 KB (16,384 bytes). That holds about 400 chained terms.
  • Brackets and NOT can nest 64 levels deep.

Errors

The filter bar checks the text as you type and underlines the problem. Point at the underline to read the message. The results stay those of the last filter that ran.

The misspelled field wrkload is underlined, and its message reads: Unknown field wrkload on Logs. Did you mean workload?

These are the most common messages.

You wroteThe filter bar saysWrite instead
workload = paymentKQL has no "="workload:payment
workload != paymentKQL has no "!="-workload:payment
workload IN (a,b)KQL has no "IN"workload:(a OR b)
workload LIKE pay%KQL has no "LIKE"workload:pay*
timeoutbare words search the log message; here add a field, for example service:checkout on traces, events and RUMbody:timeout
pod_name:xpod_name is the storage nameinstance:x
workloadx:paymentUnknown field workloadx on Logs. Did you mean workload?workload:payment

pod_name is the column name used in SQL. The filter bar calls the same field instance.

workload = payment
workload IN (a,b)
workload LIKE pay%
timeout
pod_name:x

The editor

Type a field name to see suggestions. After field:, KubeSense lists the values in the time range, with counts.

After namespace:otel-demo workload:, the bar lists the workloads in the time range with their log counts.

Press Tab to accept one, Enter to run the filter and Shift+Enter for a new line. Ctrl+Space (Cmd+Space on a Mac) opens the field list.

For API and Terraform users
  • To check a log pipeline condition through the API, set the validation target to vrl.
  • Errors carry a code. The ones named on this page are text_too_long for text over 16 KB, bad_variable for more than 500 patterns, and regex_not_allowed for a /regex/ outside a pipeline.

On this page