Splunk Search

Need to extract latest value from multiple matches?

thiru25
Explorer

Hello, The following query results in multiple results when the where condition(where msgdiff=dailypeak) is met but I want just latest result, please help?

index="ContentGateway" sourcetype=Messagestats  host="cg1-e-fid-bos-l1" 
| streamstats current=t window=2 global=f allnum=t range(Messages) as msgdiff by host source
| eval msgdiff=msgdiff/5
| rex field=source "/home/activ/ContentGateway/log/updates/MessageStatistics.(?<feed>\w*(?!\d)\w)"
| bin _time span=5s
| stats sum(msgdiff) as msgdiff by _time feed
| eventstats max(msgdiff) as dailypeak by feed 
| where msgdiff=dailypeak
| table  feed dailypeak _time

thanks,
Thiru.

Tags (1)
0 Karma
1 Solution

jonuwz
Influencer

replace

| table  feed dailypeak _time

with

| stats max(_time) as _time by feed dailypeak

View solution in original post

0 Karma

jonuwz
Influencer

replace

| table  feed dailypeak _time

with

| stats max(_time) as _time by feed dailypeak
0 Karma
Get Updates on the Splunk Community!

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...

Combine Multiline Logs into a Single Event with SOCK: a Step-by-Step Guide for ...

Combine multiline logs into a single event with SOCK - a step-by-step guide for newbies Olga Malita The ...