Count and sort events by name
Problem / Use case
You want to count how many times each name appears in your logs and then sort the result alphabetically by name. This can be accomplished with the countBy command.
Query
countby name into name_count
| orderby name
Expected output
| name | name_count |
|---|---|
| currencyservice-server | 35936334 |
| emailservice-server | 243684 |
| paymentservice-charge | 243683 |
| paymentservice-server | 386842 |
| recommendationservice-server | 6685255 |
| null | 212302149 |
Variations
To sort by descending frequency instead:
countby name into name_count
| orderby name_count desc
| name | name_count |
|---|---|
| null | 212277571 |
| currencyservice-server | 35932632 |
| recommendationservice-server | 6684555 |
| paymentservice-server | 386798 |
| emailservice-server | 243653 |
| paymentservice-charge | 243652 |