Splunk Search

eval with dynamic column names

mschellhouse
Path Finder

I have a table of data as follows:
KPI / Base:(date1) / Test:(date1) / Test:(date2) / Test:(daten)
KPI1 / 1.5 / 1.8 / 1.2 / 1.7
KPI2 / 2.1 / 2.5 / 1.9 / 2.2

I need to be able to calculate the difference between each test column to base column using eval. The test column name is dynamic as it has the date that the test was executed.

How do I handle the fact that the test column names are dynamic? They will all contain Test, or some other consistent string.

0 Karma
1 Solution

somesoni2
Revered Legend

Try something like this

your current search giving table in your ques
| rename Base* as Base
| foreach Test* [| eval "diff_<<MATCHSTR>>"=Base-'<<FIELD>>']

View solution in original post

somesoni2
Revered Legend

Try something like this

your current search giving table in your ques
| rename Base* as Base
| foreach Test* [| eval "diff_<<MATCHSTR>>"=Base-'<<FIELD>>']

mschellhouse
Path Finder

The rename didn't work but I got around that. The foreach and eval were very helpful. Thanks!

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 ...