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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...