cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Count numbers of entry in a log in Grails

Raul_CL
Observer

I have a log ingested in Grails where I would like to count the number of entries of each user. The user name is the second column.
User names are dynamic, I mean new users could appear daily.

USER user1 20231121 12:11:27 95959595 12345
USER user1 20231121 12:11:29 95959595 12345
USER user5 20231121 12:11:31 95959595 12345
USER user8 20231121 12:11:33 95959595 12345
USER user1 20231121 12:11:35 95959595 12345
USER user5 20231121 12:11:37 95959595 12345

For this example, I would like to have something like this:
user1: 3
user5: 2
user8:1

Is it possible to do that?

 

3 REPLIES 3

Miguel_RinconG
Dynatrace Advisor
Dynatrace Advisor

Yes, you can use  Dynatrace patterm language: https://docs.dynatrace.com/docs/platform/grail/dynatrace-pattern-language

stefan_eggersto
Dynatrace Mentor
Dynatrace Mentor

Hi @Raul_CL ,

This would be a query for parsing and summarizing such input:

data record(content = "USER user1 20231121 12:11:27 95959595 12345"),
record(content = "USER user1 20231121 12:11:29 95959595 12345"),
record(content = "USER user5 20231121 12:11:31 95959595 12345"),
record(content = "USER user8 20231121 12:11:33 95959595 12345"),
record(content = "USER user1 20231121 12:11:35 95959595 12345"),
record(content = "USER user5 20231121 12:11:37 95959595 12345")
| parse content, "'USER ' word:user"
| summarize count(), by:user

stefan_eggersto_0-1700636648576.png

 

Raul_CL
Observer

Thank you both very much for responding. The solution proposed by stefan_eggersto worked perfectly for me.

Featured Posts