Splunk Search

extracting eval for reuse in other searches

SimonKof
New Member

Hi

I have a dashboard which shows metrics for an API. It has a graph for response times, tables for min max average response times etc.

All the searches for these graphs includes the same eval function which groups endpoints where a variable is part of the endpoint. For example this :

index=api
| eval endpoint = replace(endpoint,"user\/\d+\/address","user/{id}/address")
| stats Count, min(executiontime), max(executiontime), avg(executiontime), stdev(executiontime) by endpoint

The above "eval endpoint ....." is used in all the dashboard panel searches.

Can it be extracted so I don't have to maintain the same eval in multiple searches?

Tags (2)
0 Karma

niketn
Legend

@SimonKof, you can create a Calculated field for your eval to reuse the same. Refer to Splunk Documentation: https://docs.splunk.com/Documentation/Splunk/latest/Knowledge/definecalcfields

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

SimonKof
New Member

Hi niketnilay

Thank you for the hint. I can't really understand how calculated fields are used.

When i go to "Calculated fields" -> "Add new" i know what to enter for destination, apply to, named and name. But what should the expression be?

It's difficult for me to find examples on this.

0 Karma
Get Updates on the Splunk Community!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

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