Splunk Search

Getting a field value from the previous event

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

Splunk Employee
Splunk Employee

Use the parameter "current=f" in streamstats.

View solution in original post

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

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

Splunk Employee
Splunk Employee

Use the parameter "current=f" in streamstats.

View solution in original post