Splunk Search
Highlighted

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
Highlighted

Re: Getting a field value from the previous event

Legend

Use the parameter "current=f" in streamstats.

View solution in original post

Highlighted

Re: Getting a field value from the previous event

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
Highlighted

Re: Getting a field value from the previous event

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
Speak Up for Splunk Careers!

We want to better understand the impact Splunk experience and expertise has has on individuals' careers, and help highlight the growing demand for Splunk skills.