Groupby

Prev Next

The groupby transform returns the unique values for a specified field and groups them together based on their frequency. You can use this transform to determine which specific field values are most or least active in your environment and to see how those values relate to other values for the same field.

Search results are displayed in a table showing the total number of values for each field. A maximum of 500 rows is displayed. To view non-grouped results, click Show Search Results.

Click arrow.png to open the sidebar where you can filter results and view the groupby pie chart.

Note

If there are more than 500 results the pie chart does not render. Refine your query and run the search again.

TAP_groupby_scap.png

Groupby Syntax

mql query [directives] | groupby [<order>] <field> [<limit>] [<threshold>]

<order>

Controls the order of the results. Must be > (descending order) or < (ascending order). When using a key/value syntax, the strings “desc” or “asc” are also acceptable. Descending order will show the most frequent occurrences; ascending order will show the least.

<field>

A field used in your environment. <field> can be any string composed of letters, numbers, and special characters that designate a field used in your environment. You may also specify a set of fields by enclosing them in brackets ( [] ). When doing so, the groupby will be performed on tuples created from the values indicated by the fields.

<limit>

Integer. Designates the maximum number of results to show. This argument is optional.

<threshold>

Integer. Designates a minimum count threshold. This argument is optional.

Note

TQL was previously called MQL. You still use and see mql in TQL queries.

Examples

Query

Result

rawmsg:* | groupby srcipv4 10 1000

The top ten srcipv4 values that have at least 1000 occurrences. See above screenshot.

tcp | groupby dstport 10 1000

The 10 most frequent ports that also have counts greater than 1000.

tcp | groupby < srcipv4 100

The 100 least frequent srcipv4 values.

tcp | groupby > srcipv4 10

The 10 most frequent srcipv4 values.

tcp | groupby > [srcipv4,dstipv4] 10

The 10 most frequent unique srcipv4_dstipv4 tuples.