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!

Strengthen Your Future: A Look Back at Splunk 10 Innovations and .conf25 Highlights!

The Big One: Splunk 10 is Here!  The moment many of you have been waiting for has arrived! We are thrilled to ...

Now Offering the AI Assistant Usage Dashboard in Cloud Monitoring Console

Today, we’re excited to announce the release of a brand new AI assistant usage dashboard in Cloud Monitoring ...

Stay Connected: Your Guide to October Tech Talks, Office Hours, and Webinars!

What are Community Office Hours? Community Office Hours is an interactive 60-minute Zoom series where ...