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!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...