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!

Building Reliable Asset and Identity Frameworks in Splunk ES

 Accurate asset and identity resolution is the backbone of security operations. Without it, alerts are ...

Cloud Monitoring Console - Unlocking Greater Visibility in SVC Usage Reporting

For Splunk Cloud customers, understanding and optimizing Splunk Virtual Compute (SVC) usage and resource ...

Automatic Discovery Part 3: Practical Use Cases

If you’ve enabled Automatic Discovery in your install of the Splunk Distribution of the OpenTelemetry ...