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
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!

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 ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...