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
Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...