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!

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...

Network to App: Observability Unlocked [May & June Series]

In today’s digital landscape, your environment is no longer confined to the data center. It spans complex ...

SPL2 Deep Dives, AppDynamics Integrations, SAML Made Simple and Much More on Splunk ...

Splunk Lantern is Splunk’s customer success center that provides practical guidance from Splunk experts on key ...