Splunk Search

How to edit my search to show the count and percentage per id for each day?

guillecasco
Path Finder

Hey.

I'm quite new with Splunk and learning for the moment. I need to show a table with " Time id count percentage "
For the last 15 days, I need to know the count of backend calls per id for each day.
I already extracted the Ids from a json file and now just need to show them as the way I described.

I'm trying some things I only have this search:

index=ips_api earliest=-15d updatesearch | rex field=summary "(?\{.*)" | spath input=json_data |timechart span=1d count by asset_data{}.id 

but it doesn't show me what I want. It just shows a table with field time and the name of each asset id in other field with the counts of each search on backend like this:

time   id12345  1269785  id9874   
4/11      85       29       5          
4/12      67       35       7    
0 Karma
1 Solution

somesoni2
Revered Legend

Try something like this

index=ips_api earliest=-15d updatesearch | rex field=summary "(?\{.*)" | spath input=json_data  | bucket _time span=1d | stats count by _time asset_data{}.id | rename asset_data{}.id  as id | eventstats sum(count) as total by _time | eval percentage=round(count*100/total,2) 
| table _time id count percentage

View solution in original post

somesoni2
Revered Legend

Try something like this

index=ips_api earliest=-15d updatesearch | rex field=summary "(?\{.*)" | spath input=json_data  | bucket _time span=1d | stats count by _time asset_data{}.id | rename asset_data{}.id  as id | eventstats sum(count) as total by _time | eval percentage=round(count*100/total,2) 
| table _time id count percentage

guillecasco
Path Finder

I missunderstood the question. Didn't have to put 15 rows for the 15 last days, Just look up in the logs of the last 15 days and extract that information. So final query (With your help somesoni2) is

index=updtr_api earliest=-15d updatesearch | rex field=summary "(?\{.*)" | spath input=json_data |stats count by asset_data{}.id | rename asset_data{}.id  as id|eventstats sum(count) as total| eval percentage=round(count*100/total) |table id count percentage

thank you!

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

It'd help if you provided some sample data along with a sketch of what your results table should look like.

0 Karma
Get Updates on the Splunk Community!

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...