Skip to main content

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​

namename_count
currencyservice-server35936334
emailservice-server243684
paymentservice-charge243683
paymentservice-server386842
recommendationservice-server6685255
null212302149

Variations​

To sort by descending frequency instead:

countby name into name_count
| orderby name_count desc
namename_count
null212277571
currencyservice-server35932632
recommendationservice-server6684555
paymentservice-server386798
emailservice-server243653
paymentservice-charge243652
Last updated on
Was this page helpful?