Splunk Search

List fields after rare command

bmer
Explorer

Hi,

Iam using below splunk to help identify least common values of runTime field in myEventRecType file . i get the results .

However I would like to also show additional fields related to the runTime like requestIdqueryExecutionTime,TimeOfExecution. How can I get them added?

Index=abc source=xxx earliest=-60m EventRecType=xyz
| rare runTime limit=5

 

Thanks!

 

Labels (3)
0 Karma

PickleRick
SplunkTrust
SplunkTrust

You can't "add" fields to the results. It wouldn't make sense anyway since "rare" is a transforming command and does aggregation on the original data so other fields' values do not correspond 1:1 to the aggregations.

What you might try doing instead is using stats (or eventstats but that's more limited).

For example:

index=abc source=xxx earliest=-60m EventRecType=xyz
| stats count values(otherField) as otherField values(anotherField) as anotherField by runTime
| sort runTime
| head 5

EDIT: I'm not editing the search because @ITWhisperer 's remark will stop making sense but indeed - the sort is on runTime whereas it should be on count.

ITWhisperer
SplunkTrust
SplunkTrust

I think you probably would want to sort by count not runTime and you can do the head in the sort

index=abc source=xxx earliest=-60m EventRecType=xyz
| stats count values(otherField) as otherField values(anotherField) as anotherField by runTime
| sort 5 count

PickleRick
SplunkTrust
SplunkTrust

You're 100% right. Since we want the rarest ones, we need to sort on count. It was late when I wrote this 😉

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Perhaps the simplest way to do this is with a subsearch, however, there are limits to the number of events so this may not work for your usecase

Index=abc source=xxx earliest=-60m EventRecType=xyz [search Index=abc source=xxx earliest=-60m EventRecType=xyz
| rare runTime limit=5
| fields runTime
| format]
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...