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

 

Get Updates on the Splunk Community!

See just what you’ve been missing | Observability tracks at Splunk University

Looking to sharpen your observability skills so you can better understand how to collect and analyze data from ...

Weezer at .conf25? Say it ain’t so!

Hello Splunkers, The countdown to .conf25 is on-and we've just turned up the volume! We're thrilled to ...

How SC4S Makes Suricata Logs Ingestion Simple

Network security monitoring has become increasingly critical for organizations of all sizes. Splunk has ...