Skip to content

countby - Count grouped values

The countby operator will generate a count for each row in a group.

NOTE: This differs from count, which will count the entire resultset, and will instead count based on a grouping key.

Syntax

countby <expression> [as <alias>] [into <keypath>]

NOTE: An alias can be provided to override the keypath the result will be written into.

Example - Count the number of requests by HTTP Status Code

A simple calculation to perform on HTTP request logs is to count by HTTP status code.

countby status_code

We can also name our count column using the into keyword:

countby status_code into request_count