Splunk Search

Getting a field value from the previous event

OL
Communicator

Hi all,

I'd like to retrieve a field value from the previous event. I've used streamstats last(myfield), but this takes the value from the current event and not from the previous one.

Explanation: I have:

  1. field1=abc, field2=abc2
  2. field1=def, field2=def2
  3. field1=ghi, field2=ghi2

I'd like to have:

  1. field1=abc, field2=abc2, oldfield2= (or nothing)
  2. field1=def, field2=def2, oldfield2=abc2
  3. field1=ghi, field2=ghi2, oldfield2=def2

Using "streamstats last()" gives me:

  1. field1=abc, field2=abc2, oldfield2=abc2
  2. field1=def, field2=def2, oldfield2=def2
  3. field1=ghi, field2=ghi2, oldfield2=ghi2

Would anyone have any idea?

Regards,
Olivier

Tags (1)
0 Karma
1 Solution

gkanapathy
Splunk Employee
Splunk Employee

Use the parameter "current=f" in streamstats.

View solution in original post

OL
Communicator

It seems to have a documentation mistake on the default value for the "current" parameter. It mentions the default is be false while if you don't set this parameter in the command, it sets it to true! I'm using version 4.2.2, build 101277.

Thank you very much for your answer.

Regards, Olivier

0 Karma

Lowell
Super Champion

You can add a comment/note to the docs (online), or email docs@splunk.com. Otherwise this comment may go unnoticed.

0 Karma

gkanapathy
Splunk Employee
Splunk Employee

Use the parameter "current=f" in streamstats.

Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...