Reference: Advanced question syntax in Console and Interact

You can issue complex questions in natural language without understanding the precise associated syntax. When you start typing a free-form question in one of the Tanium Console or Interact question fields, the Tanium natural language parser evaluates your entry and proposes a question in valid syntax, as described in Issue a free-form question. However, understanding the syntax is useful if you want to edit the proposed question, add filters or options, reuse the question in other contexts, or learn more about the question results. For example, you can issue a question with the Computer Name sensor filtered to return results only from endpoints that match a case-sensitive character string.

Use question filters

Each Tanium question has a get clause that specifies the information to retrieve and a from clause that specifies the target endpoints. You can add filters to both clauses when you issue a question.

Filters in get clause

In a Tanium question, the get clause specifies the sensors that Tanium Clients run to answer the question. Clients apply any filters to the sensor results and return the filtered results to the Tanium Server. Interact then shows the filtered results in the Question Results page. For example, if the get clause specifies Get Running Processes contains chrome, Clients filter the Running Processes sensor to show processes with names that contain the string chrome. Clients return the answer [no results] if no results match the filter. In this example, Clients return [no results] if they have no running processes that contain chrome.

Figure 1. Filter in Get clause of question
Filter in get clause

Filters in from clause

In a Tanium question, the from clause specifies whether the question targets all Tanium Client (from all machines) or only Tanium Clients that evaluate the filtering sensor to a Boolean true. For example, the question Get Running Processes from all machines with CPU Consumption > 80% returns the names of all running processes on endpoints managed using Tanium Client where CPU consumption exceeds 80%.

Note:

Regardless of targeting filters, you can see question results only from endpoints that are in computer management groups that are assigned to the user account or alternative persona that you use for the current Console session. For more information, see Computer groups in questions.

You also use filters to define the dynamic membership of computer management groups and filter groups. For more information, see Computer group membership.

For more information about from clause filters, see Questions with target filters.

Figure 2. Filter in From clause of question
Filter in from clause

Exclude [no results]

Use a combination of get and from filters in a question if you want the Question Results page to exclude Clients that return [no results]. For example, the following question shows processes with names that contain the string chrome but only on Clients that have at least one process name with that string.

Figure 3. Filter to exclude [no results]
Filter in get and from clauses

Filter operators

Filter expressions in questions can match strings or regular expressions. The following table describes the supported filter operators as they appear when you use the Interact Filter Builder Question Builder. The table also describes how some operators are normalized after you enter the expressions in the Ask a Question field or issue a question from the Question Builder.

Note:

If you use operators that evaluate integer results from sensors and a Tanium Client returns a string result instead (such as true, false, or an error), Interact interprets the error string as the value 0. For example, if a Client returns TSE-Error for a question with the filter installed application version[chrome] <= 12, the filter evaluates to true for that Client because Interact interprets TSE-Error as a 0 value. Adding the filter and <sensor> not equals 0 causes Interact to evaluate strings to false in such cases, but also evaluates non-string 0 values to false.

If you use operator words as string literals instead of as filters in question text, you must enclose the words in quotation marks. For more information, see Use reserved words or characters.

Table 1. Filter operators

Filter operator

Usage

contains

The sensor value contains the specified string.

Example: running processes contains "chrome"

does not contain

The sensor value does not contain the specified string.

starts with

The sensor value starts with the specified string.

Example: starts with "chrome"

When you issue the question, the expression is translated to a regular expression using the matches operator.

does not start with

The sensor value does not start with the specified string.

ends with

The sensor value ends with the specified string.

Example: ends with "chrome.exe"

When you issue the question, the expression is translated to a regular expression using the matches operator.

does not end with

The sensor value does not end with the specified string.

matches

The sensor value matches the specified regular expression. For more information, see Use regular expression filters.

For sensors in the get clause of a question, use the matches operator to match any value in a list. In the Ask a Question field, enclose the values in quotation marks and parentheses "( )", and use the pipe character | as a separator. In the Question Builder, you can skip the quotation marks; Interact adds them automatically when you issue the question. For example, the following question matches the user names root or reboot:

Get Last Logged In User matches "(root|reboot)" from all machines

In the from clause of a question, you can also use the in operator to match values in a list.

does not match

The sensor value does not match the specified regular expression.

When you issue the question, the expression shown in the question field uses not matches in place of does not match.

in (from clause only)

The sensor value is equal to one of the specified strings. Enclose the values in parentheses and use commas as separators.

When you issue the question, the question field shows the expression with equals in place of in and with or in place of commas.

Example: the filter with Chassis Type in (Virtual,Physical) in the Ask a Question field becomes with (Chassis Type equals Virtual or Chassis Type equals Physical) when you issue the question.

For more information, see Use the "in" operator for filtering.

Note: In the get clause of a question, the in operator is not available but you can use the matches operator instead.

is equal to

The sensor value is equal to the specified value or string.

When you issue the question, the expression shown in the question field uses equals in place of is equal to.

is not equal to

The sensor value is not equal to the specified value or string.

When you issue the question, the expression shown in the question field uses not equals in place of is not equal to.

is less than

The sensor value is less than the specified value.

When you issue the question, the expression shown in the question field uses a symbol (<) in place of the operator words.

Example: installed application version[chrome] < 12

is less than or equal to

The sensor value is less than or equal to the specified string.

When you issue the question, the expression shown in the question field uses symbols (<=) in place of the operator words.

Example: installed application version[chrome] <= 12

is greater than

The sensor value is greater than the specified value.

When you issue the question, the expression shown in the question field uses a symbol (>) in place of the operator words.

Example: installed application version[chrome] > 12

is greater than or equal to

The sensor value is greater than or equal to the specified string.

When you issue the question, the expression shown in the question field uses symbols (>=) in place of the operator words.

Example: installed application version[chrome] >= 12

Use reserved words or characters

Reserved words or characters in question text

The Tanium™ parser uses certain words and characters to interpret the question text that you enter as valid query syntax. For example, the parser uses the bracket characters [ and ] to enclose the values of parameterized sensors and uses variations of the word match to support regular expressions. You must enclose these reserved words and characters in quotation marks when you use them as string literals in questions. For example, to see all endpoints that have computer names containing the letter combination in, issue the question Get Computer Name from all machines with Computer Name contains "in".

Characters that require quotation marks in questions

  • "

    Use double quotation marks as an escape-character sequence for each instance of quotation marks in a text string. For example, to see which endpoints have a computer name that contains the string "test", issue the question:

    Get Computer Name from all machines with Computer Name contains """test"""

  • .

  • ,

  • :

  • ?

  • $

  • White spaces

    For example, to see which endpoints have a computer name that has a blank space before and after the string DBserver, issue the question:

    Get Computer Name from all machines with Computer Name contains " DBserver "

Words that require quotation marks in questions

  • all

  • and

  • any

  • contain

  • containing

  • contains

  • does match

  • does not match

  • ending

  • ends

  • equals

  • get

  • having

  • in

  • matches

  • matching

  • not

  • or

  • with

  • starting

  • starts

Reserved words in sensor names

Sensors with names that use reserved words require quotation marks when you use them as string literals in the Interact Ask a Question field. Otherwise, the dropdown list that displays suggested questions cannot accurately match your entry. For example, if you enter the Running Processes with MD5 Hash sensor without quotation marks, the dropdown list displays suggestions that confuse your entry with other sensors that contain the words MD5 Hash:

Figure 4. Sensor name without quotations
Sensor name without quotations

If you use quotation marks around the sensor name, the dropdown list displays the correct question:

Figure 5. Sensor name with quotations
Sensor name with quotations

Reserved words in sensor names

  • $serverNames

  • $serverIDs

  • $substring

  • $unescape

  • all

  • All

  • ALL

  • and

  • any

  • computers

  • Computers

  • COMPUTERS

  • contains

  • containing

  • equals

  • from

  • From

  • FROM

  • get

  • Get

  • GET

  • having

  • Having

  • HAVING

  • in

  • machines

  • Machines

  • MACHINES

  • matches

  • matching

  • not

  • number

  • Number

  • NUMBER

  • of

  • Of

  • OF

  • or

  • where

  • Where

  • WHERE

  • with

  • With

  • WITH

Use regular expression filters

Tanium questions support regular expression (regex) matching in both the get statement and from clause. Regex filters provide great flexibility for specifying the exact information to retrieve and the specific endpoints to query.

Note: You can also use regular expressions to define the membership of computer groups. For more information, see Computer group membership.

Processing limits for regular expressions

The Tanium Core Platform stops processing regular expressions that run for an excessive amount of time to protect against the misuse of platform resources. For example, if complex regular expressions in a question cause it to exceed the limit for processing resources, the Tanium Client stops processing that question and returns [no results] for it.

The following types of regular expressions might exceed the resource limit:

  • Negative lookaheads (?! syntax), such as (?!tool)ai.*

  • Positive lookaheads (?= syntax), such as (?=tool)ai.*

  • Named capture groups (?<group-name> syntax), such as ?<year> in the expression /(?<year>\d{4})-\d{2}|\d{2}-(?<year>\d{4})/

Example: Match a starting character

The following regular expression matches computer names that start with the letter q in the domain tanium.com.

Figure 6. Regular expression to match initial character
Regular expression to match initial character

Example: Match any digit

The Detect Primary Alerts sensor uses a regular expression to collect results that match any digit in the range 0 to 9. Because alerts have numeric IDs, this expression excludes empty results.

Figure 7. Regular expression to match any digit
Regular expression to match any digit

Example: Negation

You can also use a combination of negation and regular expressions to build filter expressions. For example, the predefined computer group No Computers has a membership definition that uses a question with the not matches expression and a regular expression (.*) to match empty results. Because the Computer Name sensor always returns a string, this combination provides a way to prevent action deployment. To stop the Tanium Server from deploying certain actions to any endpoints, configure those actions to target the Default action group, which includes only the No Computers computer group.

Figure 8. Regular expression with negation
Regular expression with negation

Use computer group filters

You can issue questions with a computer group filter in the from clause to ensure that only endpoints in the group respond. The computer group can be a management group or filter group. For more information about these types, see Controlling endpoint management rights through computer groups.

Use quotation marks around the computer group name when you enter it in the from clause. For groups with dynamic (filter-defined) membership, the question parser converts the specified group name into a question that determines membership. For more information, see Computer group membership.

Figure 9. Question with computer group in From clause
Question with computer group in From clause

Use sensor column filters

Multi-column sensors are designed to collect multiple pieces of related information in a single answer. For example, the Installed Applications sensor returns four columns of information, as shown in the figure Sensor column filter in the Get and From clauses of a question. Using the regular expression starts with, ends with, or contains in a question to filter results for a multi-column sensor can be tricky because the sensor result string is actually a single string with column delimiters. If you enter the filter incorrectly, you might match a string in an unexpected column or unknowingly match a string in a hidden column. To avoid unintended results, you can specify a particular column for results matching. The syntax is get <sensor> having <sensor>:<column> contains <value>. The column name is case sensitive.

Single-column filtering works only if the sensor configuration specifies column delimiters with a single character (such as |), not multiple characters (such as |:). For more information, see Split into multiple columns. To match results from all the columns, the syntax is get <sensor> contains <value>.

The following example shows a sensor column filter in the get clause of a question.

Figure 10. Sensor column filter in the Get clause of a question
Sensor column filter in the Get clause of a question

The following example shows a sensor column filter in both the get clause and the from clause of a question and shows the results.

Figure 11. Sensor column filter in the Get and From clauses of a question
Results of sensor column filter in Get and From clauses of question

Use $substring() filters

You can use $substring() filters in questions to match result string patterns. The $substring() function takes the following arguments: sensor name, starting position (where 0 is the first position), number of characters.

The following example matches results from the Installed Applications sensor where the first two characters match the string Go.

Figure 12. $substring() filter in a question
$substring() filter in a question
Note: In a multi-column sensor, the $substring() filter applies across all the columns. You cannot apply the $substring() filter to a specific column.

Use the "in" operator for filtering

In the from clause of a question, use the in operator to specify a collection of matching sensor results. The in operator applies the is equal to operator to any value in a comma-separated list that you enclose in parentheses. After you issue the question, the question field shows the expression with equals in place of in and with a Boolean or in place of commas.

Note: In the get clause of a question, the in operator is not available but you can use the matches operator instead.

The following example shows the in operator applied to results containing Virtual or Physical.

Figure 13. Question with "in" operator
Question with "in" operator
The following example shows the question syntax after you issue the question.
Figure 14. Issued question with "in" operator
Issued question with "in" operator
Question with "in" operator

The following question applies the in operator to values (115.0.1901.188 or 115.0.1901.200) in a specific column (Version) of the multi-column sensor (Installed Applications):

PYTHON
Get Installed Applications having Installed Applications:Name equals Microsoft Edge from all machines with ( Installed Applications:Name equals Microsoft Edge and Installed Applications:Version?type=Version in (115.0.1901.188,115.0.1901.200 ) )
Figure 15. Question with "in" operator applied to a sensor column filter
Question with "in" operator applied to a sensor column filter

After you issue the question, its syntax changes to:

PYTHON
Get Installed Applications having Installed Applications:Name equals Microsoft Edge from all machines with ( Installed Applications:Name equals Microsoft Edge and ( Installed Applications:Version?type=Version equals 115.0.1901.188 or Installed Applications:Version?type=Version equals 115.0.1901.200 ) )

Use nested filters

In the from clause of a question, you can configure multiple filters, including nested filters.

The following example shows nested filters in the Filter Builder Question Builder. The example combines one matching expression with either one of the nested expressions.

Figure 16. Nested filters in the Question Builder
Nested filters in the Question Builder

You can also specify nested filters in the Ask a Question field.

Figure 17. Nested filters in the Ask a Question field to match either of two results
Nested filters in the <uicontrol>Ask a Question</uicontrol> field to match either of two results

The following example shows different Boolean logic: match both of these or this one.

Figure 18. Nested filters in the Ask a Question field to match both results or one result
Nested filters in the <uicontrol>Ask a Question</uicontrol> field to match both results or one result

Target random endpoints

Use the Online Random Sample sensor to identify a random subset of online endpoints managed using Tanium Client from all targeted endpoints. You might want to target random endpoints when you test a new package or configuration on a random subset of endpoints, or to check a random set of endpoints to ensure they have proper configurations prior to an audit. The Online Random Sample sensor is included in the content-only solution Default Content.

The Online Random Sample sensor retrieves True and False results from all targeted endpoints. The sensor accepts a Sample % parameter from 0-100 to determine the rough percentage of endpoints that answer with True. For example, if you pass 25 as a parameter and target from all machines, approximately 25% of endpoints in the environment will return a True response. Because each endpoint evaluates the sensor and generates a random True or False answer according to the percentage that you specify, the number of endpoints that return True can vary. The default value for Sample % is 5.

Figure 19. Online Random Sample sensor
Online Random Sample sensor

Use advanced sensor options

Question results from Tanium Clients must conform with any advanced options that you specify for sensors in the question. You can configure advanced sensor options in the Filter Builder Question Builder (see Question Builder: Advanced sensor options) or the Ask a Question Ask a Question field.

Figure 20. Question Builder: Advanced sensor options
Question Builder: Advanced sensor options

In the Ask a Question field, all sensor options use the syntax format <sensor>?<option>=<value>. To specify multiple advanced options for a sensor, separate each option with an ampersand &: <sensor>?<option 1>=<value>&<option 2>=<value>...&<option N>=<value>. The following example shows a question with two options for the Installed Applications sensor.

Get Installed Applications?ignoreCase=0&maxAge=120 contains A from all machines

The following sections describe the advanced sensor options and provide examples of their syntax in the Ask a Question field.

Case Sensitivity

Select whether Interact accounts for upper-case and lower-case characters when grouping and counting question results that contain letters.

In the Question Builder, the options are:

  • Ignore case

  • Match case

In the Ask a Question field, the syntax is <sensor>?ignoreCase=[0|1]. The value 0 means match the case and the value 1 means ignore the case. The following example specifies the Case Sensitivity option with a value set to Match Case.

Get Installed Applications having Installed Applications:Name?ignoreCase=0 contains A from all machines

Note: If you omit Case Sensitivity, the Ignore case in result values setting in the sensor configuration controls case sensitivity for grouping and counting results. For more information, see Ignore case in result values.

Matching

If the Tanium Client computes multiple results for certain sensors, you can use the Matching option as a filter such that the Client answers the question only if its results conform to your selection. For example, a Client with multiple interfaces returns multiple results for the IP Address sensor. You can specify matching to return results only from Clients on which all the interfaces have an IP address that contains the string 192.

In the Question Builder, this option is available only in the from computers with section, and the options are:

  • Match Any Value: The Client returns results if any of its results match the sensor value.

  • Match All Values: The Client returns results only if all its results match the sensor value.

In the Ask a Question field, this option is available only in the from clause. The syntax is with [all] <sensor> contains <value>, where omitting the all option specifies Match Any Value. In the following example, the Matching option is set to Match All Values (with all) for the IP Address sensor.

Get IP Address from all machines with all IP Address?type=String contains 192

Treat Data As

Interact treats sensor values as the type of data that you specify. For descriptions of the data types that you can select in the Question Builder, see Result Type.

In the Ask a Question field, the syntax for filtering by data type is <sensor>?type=<type>. The following example specifies Numeric as the type.

Get Free Memory?type=Numeric > 300 from all machines

The File Size data type in the Question Builder corresponds to the DataSize type in the Ask a Question field, where the syntax is <sensor>?type=DataSize. The following example returns results from endpoints where the installation folder of the Tanium Client is at least 10 GB.

Get Tanium Client Folder Size?type=DataSize >= 10 GB from all machines

Note: Use the Treat Data As option only with comparison operators, such as > and >= in the preceding examples.

Maximum Data Age

Specify the maximum time for which the Tanium Client can use a cached result for the sensor, instead of re-running it for a fresh result, when answering questions. For example, you might specify 15 minutes for the File Size sensor. When a Client receives a question that runs the File Size sensor, it caches the result. Over the next 15 minutes, if the Client receives another question with the File Size sensor, it returns the cached result. After 15 minutes, if the Client receives a question with the File Size sensor, it re-runs the sensor script to return a fresh result.

To improve the accuracy of results, use shorter ages for sensors with values that change frequently, such as status and usage sensors. To reduce unnecessary resource consumption on endpoints, use longer ages only for sensors with values that typically do not change frequently, such as the chassis type or Active Directory domain membership.

In the Question Builder, you can specify the Maximum Data Age units (minutes, hours, days). In the Ask a Question field, the syntax is <sensor>?maxAge=<value> and the units are always seconds. The following example specifies a maximum age of 3600 seconds.

Get Computer Name?maxAge=3600 from all machines

Note: If you omit the Maximum Data Age, the Max Sensor Age setting in the sensor configuration determines the maximum time for cached results. For more information, see Max Sensor Age.
Note: Specify a Maximum Data Age only when issuing dynamic questions, not when creating saved questions that periodically reissue or when configuring endpoint membership in computer management groups and filter groups. Setting a Maximum Data Age that is lower than the Max Sensor Age increases CPU usage on endpoints.

Use advanced question options

Enable the Force Computer ID option to convert a single-sensor, counting question into a non-counting question by forcing Tanium Clients to include the computer ID in their answers. Note that the Question Results page does not include the computer ID results when you select this option. Converting to a non-counting question is a workaround that resolves cases where a counting question returns the too many results answer. For more information, see Too many results. You can enable the option in the Ask a Question field by using the Get?forceComputerIdFlag=1 statement. You can also enable the option in the Question Builder, under Advanced Question Options.