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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...