Splunk Search

How to find most common tag values when each event has multiple tags?

ehennessey_splu
Splunk Employee
Splunk Employee

I've got a data source in which each item contains multiple tag fields describing the item. For simplicity's sake, we'll say each has five tags, not all of which must be used. So given this scenario:

Item 1: tag1=oranges tag2=trees tag3=groves
Item 2: tag1=trees tag2=apples tag3=groves
Item 3: tag1=vines tag2=vineyards tag3=grapes
Item 4: tag1=bowls tag2=assortments tag3=apples tag4=tangerines

What search terms will tell me I've got 2 occurrences of apples, 2 of trees, 2 of groves, 1 of grapes, and so on?

0 Karma

woodcock
Esteemed Legend

This spoofs the data:

| makeresults 
| eval raw="Item 1: tag1=oranges tag2=trees tag3=groves:::Item 2: tag1=trees tag2=apples tag3=groves:::Item 3: tag1=vines tag2=vineyards tag3=grapes:::Item 4: tag1=bowls tag2=assortments tag3=apples tag4=tangerines" 
| makemv delim=":::" raw 
| mvexpand raw
| rename raw AS _raw
| rex "^Item (?<Item>\d+): tag1=(?<tag1>\w+) tag2=(?<tag2>\w+) tag3=(?<tag3>\w+)(?: tag4=(?<tag4>\w+))?"

This is your solution:

| fields - Item
| untable _time key value
| stats count BY value
0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...