Monitoring Splunk

Can we improve on a standard index=index_name sourcetype=*prod | stats query?

ddrillic
Ultra Champion

We have this standard query -

index=<index name> sourcetype=*prod clientID=*aaa OR clientID=bbbb OR clientID=*ccc OR clientID=*ddd
|  stats count by  clientID apiName
|  eval applicationName=case(
clientID="<client_id>", "<nicer name>", 
....)
|  fields - clientID
|  fields applicationName apiName count
|  sort applicationName

Are there more performant options for such a query?

Tags (1)
0 Karma
1 Solution

adonio
Ultra Champion

if those are indexed extractions (at index or using datamodel acceleration) you can do this:

 |  tstats count where index=<index name> sourcetype=*prod clientID=*aaa OR clientID=bbbb OR clientID=*ccc OR clientID=*ddd by  clientID apiName
     |  eval applicationName=case(
     clientID="<client_id>", "<nicer name>", 
     ....)
     |  fields - clientID
     |  fields applicationName apiName count
     |  sort applicationName

View solution in original post

0 Karma

adonio
Ultra Champion

if those are indexed extractions (at index or using datamodel acceleration) you can do this:

 |  tstats count where index=<index name> sourcetype=*prod clientID=*aaa OR clientID=bbbb OR clientID=*ccc OR clientID=*ddd by  clientID apiName
     |  eval applicationName=case(
     clientID="<client_id>", "<nicer name>", 
     ....)
     |  fields - clientID
     |  fields applicationName apiName count
     |  sort applicationName
0 Karma

ddrillic
Ultra Champion

Much appreciated @adonio.

0 Karma

ddrillic
Ultra Champion

Very interesting @adonio - thank you.

0 Karma

cmerriman
Super Champion

i MAY be mistaken, but if you put fields at the beginning, it might be helpful, so splunk only grabs relevant fields and isn't looking at anything else.
index= sourcetype=*prod clientID=*aaa OR clientID=bbbb OR clientID=*ccc OR clientID=*ddd
| fields clientID apiName
| stats count by clientID apiName
| eval applicationName=case(clientID="", "", ....)
| fields - clientID
| sort applicationName

ddrillic
Ultra Champion

Makes perfect sense @cmerriman!!

0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...