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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...