Splunk Search

Extract the meaningful fields from the logs

amitru
Engager

I want to get an API usage report per user and I am struggling with the Splunk Query for this, can someone please help with the query, I tried using rex but didn't get through.

 

In my app logs, I have a text like -

U87XXXX:ddddffggggggsss.REG.Currency [RestInterceptor]: RestRequest: URI : https://abc.net/api/curr

........  RequestBody: {"loginId": "U87XXXX"}

 

I want the output as

UserID                     URL                                                 COUNT 

U87XXXX        https://abc.net/api/curr                    5

U78XXXX       https://abc.net/api/xyz                     11 

 

Thanks in advance.

Labels (1)
0 Karma

Gr0und_Z3r0
Contributor

Hi @amitru 

Try something like this and then do a stats command to get insights.


 

|rex field=_raw "URI\s\:\s(?P<URL>[\w\:\/\.]+)"
|rex field=_raw "loginId\"\:\s\"(?P<UserID>[\w]+)\""
|stats count by UserID URL

 

Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...