Splunk Search

How to get change events only?

eranhauser
Path Finder

I  have events with the following keys: key1, key2 & key3.

I would like to get the change events i.e. events that their key1, key2 & key3 values are not in the events of previous day. 

What should the query look like?

Labels (1)
Tags (1)
0 Karma

bowesmana
SplunkTrust
SplunkTrust

What data is the correlation between the same event - please give an example of the data you may see and what you would expect.

For example, if you have an event yesterday with 

key1=A, key2=B,key3=C

and an event today with

key1=A, key2=B,key3=D

what do you want to show? If you have lots of events with different fields, is there some common object that connects those events to today's events?

0 Karma

eranhauser
Path Finder

a change event is considered if any combination of key1, key2 & key3 is new. In your example key1=A, key2=B,key3=D will be considered as a new event.

0 Karma

bowesmana
SplunkTrust
SplunkTrust

then something like

index=your_index earliest=-1d@d latest=now()
``` Collect all combinations of key 1, 2 and 3 by day ```
| bin _time span=1d
| stats count by _time key1 key2 key3
``` Count the number of days these key combinations occur ```
| stats dc(_time) as times list(_time) as days by key1 key2 key3
``` and then if there is only 1 variant and it is today, it's a new type ```
| where times=1 AND days=relative_time(now(), "@d")
0 Karma

eranhauser
Path Finder

There should be something similar to SQL in splunk like right outer joint no? 

0 Karma

bowesmana
SplunkTrust
SplunkTrust

There is a join command, but it is NOT the first, second or third choice for a Splunk solution - you can and should always use stats to join data. join has limitations, requires a second search to do the join data.

This stats command is effectively calculating all the similar triplets by time and where there are two times (e.g. 2 days) you have a non-change event, so discard it.

 

0 Karma
Get Updates on the Splunk Community!

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk on November 6 at 11AM PT, and empower your SOC to reach new heights! Duration: ...

Splunk Observability as Code: From Zero to Dashboard

For the details on what Self-Service Observability and Observability as Code is, we have some awesome content ...