Splunk Search

Deduping one field for each of another field

0cool
New Member

I'm looking for a way to dedup a given field for each instance of another field. More specifically:

| eval warningIssued=if(transtype="Show Page" AND failed_policy="OS Patches - Download and Install::OS Patches NOT set to Automatic", 1, 0) | eval nowCompliant=if(compliant_policy="OS Patches - Download and Install::OS Patches set to Automatic",1,0) |

Following this string, I would like to get rid of everything but the earliest event where warningIssued=1 for EACH MAC address, and the earliest event where nowCompliant=1 for EACH MAC address. Is there any way to dedup this way?

Tags (1)
0 Karma

kristian_kolb
Ultra Champion

I think this could work.

your_search |  search warningIssued=1 OR nowCompliant=1 | reverse | dedup MAC warningIssued nowCompliant | whatever_comes_next

but it will be rather slow, since reverse will not make splunk search oldest-first, it just re-sorts the events once they are all in. If you have a large number of events, or a long time span, this can be quite prohibitive.

The dedup will find the (chronologically, since events are resorted) first unique combinations of MAC, warningIssued and nowCompliant.

This assumes that these fields are present in the events. You might have to add keepempty=true to the dedup command, depending on whether all three fields are always present in an event or not. Also I might have misunderstood the documentation.

Hope this helps,

Kristian

0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...