Splunk Search

Streamstats with rex and multiple "by" fields

RobK700000
Engager

I am attempting to rex out some fields from a source log and then if FIELD1 changes in a 24 hour period when the other 4 FIELDS all remain the same then output that information. Basically we should only be issuing FIELD1 once every 24 hours and if we issue it more than once but the other fields are all the same during that time frame then we know something is wrong. Unfortunately I've been banging on this for a few hours and I cannot get it to work. Can anyone assist. Thanks 

index=<index> AND source="source.log"
| rex "\"field1\":\"(?<FIELD1>[^\"]*)\""
| rex "\"field2\":\"(?<FIELD2>[^\"]*)\""
| rex "\"field3\":\"(?<FIELD3>[^\"]*)\""
| rex "\"field4\":\"(?<FIELD4>[^\"]*)\""
| rex "\"field5\":\"(?<FIELD5>[^\"]*)\""
| fields FIELD1, FIELD2, FIELD3, FIELD4, FIELD5
| streamstats time_window=24h last(FIELD1) as prev_field_value by FIELD2,FIELD3,FIELD4,FIELD5
| where FIELD1 != prev_field_value
| fields prev_field_value
|table _time FIELD1 FIELD2 FIELD3 FIELD4 FIELD5

Labels (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Events will be processed reverse chronological order, so unless you resort them, you might want first rather than last

| streamstats time_window=24h first(FIELD1) as prev_field_value by FIELD2,FIELD3,FIELD4,FIELD5

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

Events will be processed reverse chronological order, so unless you resort them, you might want first rather than last

| streamstats time_window=24h first(FIELD1) as prev_field_value by FIELD2,FIELD3,FIELD4,FIELD5
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Unlocking Unified Insights: New Gigamon Federated Search App for Splunk

In today’s data-heavy environment, organizations are caught in a data distribution dilemma. As data volumes ...

GA: New Data Management App in Splunk Platform

Streamlining Data Management: Introducing a unified experience in Splunk Managing data at scale shouldn’t feel ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...