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!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...