Splunk Search

How to select values from not the current source but from the previous source

PBerry7538
New Member

So I know that the following will allow me to search and just to select values from the current sourcetype :

[search index= sourcetype="" | stats latest(source) as source | return source] < SPL QUERY>

But i would like to select values from the previous current source ( I am sorry if explaining badly) . Please could anyone help me with how I could do that.

Many Thanks

Tags (1)
0 Karma
1 Solution

whrg
Motivator

Try this:

[search index=...  sourcetype=... | dedup source | head 2 | reverse | head 1 | return source] < SPL-QUERY>

Alternatively:

[search index=... sourcetype=... | dedup source | streamstats count | search count=2 | return source] < SPL-QUERY>

View solution in original post

0 Karma

PBerry7538
New Member

@whrg
Thanks very much ! That worked a treat

0 Karma

whrg
Motivator

Try this:

[search index=...  sourcetype=... | dedup source | head 2 | reverse | head 1 | return source] < SPL-QUERY>

Alternatively:

[search index=... sourcetype=... | dedup source | streamstats count | search count=2 | return source] < SPL-QUERY>
0 Karma
Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

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