Splunk Search

Using Stats command to outputlookup Vs using table command

macadminrohit
Contributor

Hi,

To increase the performance of the search can we use stats command rather than table command to output the results to a lookup table?

Tags (1)
0 Karma

DalJeanis
Legend

You might also want to look at using tstats if those are indexed fields. See if this gives you your desired result...

| tstats latest(Status) as Status where index=summary by Space Description 
0 Karma

niketn
Legend

@macadminrohit, if you want statistically aggregated data to be pushed to lookup file then definitely yes.

Do you mind sharing the current query with table and corresponding stats command?

Is the number of result and the data pushed to the lookup file through table and stats the same? If they are the same then use Job Inspector to check which query performs better.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

macadminrohit
Contributor

Hi Niket,

Here is the query :

index=summary Space=*
| stats latest(Status) as Status by Description Space
| table Space, Description, Status

The number of results are same and the time taken in using table command is almost 3 times more as shown by the job inspector.

I think here we are using table command to just rearrange the fields. Any recommendation of using stats command get the fields in the order as per our requirement. We are trying to output the result in a lookup file where order matters.

0 Karma

somesoni2
Revered Legend

You can just use this to get things in order your need. The output field order is same as how you specify them in stats command. You first get all the fields that you specify in by clause, from left to right, then you get all the fields used in aggregate functions, again left to right.

index=summary Space=*
| stats latest(Status) as Status by Space Description 
0 Karma

macadminrohit
Contributor

Want to mark this as the answer.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...