Splunk Search

latest for eventstats does not work

collier31200
Explorer

Hello,

I try to use the latest() option of eventstats in the following way:

| eventstats latest(Status) AS Status_last by Application |sort 0 _time| dedup _raw| table _time  Status Status_last 

In fact, I used a regex to define "Status" in a log line and I want to display the Current Status (current log line) and the status value of the previous logs line.

As below the problem is the Status_last raised is not good.

_time Status Status_last
2015-03-31 19:28:05 DEGRADED OPERATIONAL
2015-03-31 19:29:05 OPERATIONAL OPERATIONAL <= instead of Degraded

Please help ! !!

Tags (3)
0 Karma
1 Solution

woodcock
Esteemed Legend

OK, like this:

... | dedup _raw | reverse | streamstats current=f last(Status) AS PrevStatus BY Application | reverse | dedup Application | table _time Applicatoin Status PrevStatus

View solution in original post

woodcock
Esteemed Legend

OK, like this:

... | dedup _raw | reverse | streamstats current=f last(Status) AS PrevStatus BY Application | reverse | dedup Application | table _time Applicatoin Status PrevStatus

collier31200
Explorer

Perfect ! That's work ! Thanks a lot

0 Karma

richgalloway
SplunkTrust
SplunkTrust

latest(Status) finds the most recent value of Status, not the previous value.

---
If this reply helps you, Karma would be appreciated.
0 Karma

collier31200
Explorer

Therefore how could I find the previous value ?

0 Karma
Get Updates on the Splunk Community!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...