Splunk Search

Add latest field with a filter to table that also displays unfiltered rows

mrminks
Engager

Hi All, newbie here - Sorry if my subject is poorly worded, I'm a little confused!

I'm trying to add a field to the table below that will show how long it's been since the last test failed.  This table also contains a column that shows the last time a test ran (pass or fail). Here's a picture.

splunkQuestion.png

Here's my current search:

index="redacted" | rex field=runtime "^(?<seconds>\w*.\w*)" |stats latest(result), latest(_time) as last_checked, latest(runtime) as lastRuntime, avg(seconds) as averageRuntime by test
| eval averageRuntime=round(averageRuntime,0)
| strcat averageRuntime f2 " seconds." field3 averageRuntime
| `timesince(last_checked,last_checked)`

 

Any ideas or tips are greatly appreciated. Thanks in Advance.

Labels (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Try something like this

|stats latest(result), latest(eval(if(result="failed",_time,null()))) as last_failed, latest(_time) as last_checked, latest(runtime) as lastRuntime, avg(seconds) as averageRuntime by test

View solution in original post

mrminks
Engager

Wow this is exactly what I wanted!  I spent hours trying to figure this out.  Thanks again for the clear instructions

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try something like this

|stats latest(result), latest(eval(if(result="failed",_time,null()))) as last_failed, latest(_time) as last_checked, latest(runtime) as lastRuntime, avg(seconds) as averageRuntime by test
Get Updates on the Splunk Community!

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

New Release | Splunk Cloud Platform 10.1.2507

Hello Splunk Community!We are thrilled to announce the General Availability of Splunk Cloud Platform 10.1.2507 ...

🌟 From Audit Chaos to Clarity: Welcoming Audit Trail v2

&#x1f5e3; You Spoke, We Listened  Audit Trail v2 wasn’t written in isolation—it was shaped by your voices.  In ...