Splunk Search

Matching data across columns

robwx
New Member

Hi,
I'm trying to work out how I can display values from a column based on a unique number appearing in another column. Here's what I'm working with:

Col1    Col2
Item_0  Monkey
Item_1  Tiger
Item_2  Gorilla
Type_0  1
Type_1  1
Type_2  0

For example, Item_0 and Type_0 need to line up, resulting in Monkey 1, Item_2 and Type_2 is Gorilla 0 etc.

Thanks in advance, Splunk ninjas!

Tags (3)
0 Karma

woodcock
Esteemed Legend

Like this:

| makeresults 
| eval _raw="Col1,Col2
Item_0,Monkey
Item_1,Tiger
Item_2,Gorilla
Type_0,1
Type_1,1
Type_2,0" 
| multikv forceheader=1 
| table Col1 Col2

| rename COMMENT AS "Everything above generates sample event data; everything below is your solution"

| rex field=Col1 "_(?<which>\d+)$"
| stats values(*) AS * BY which
| foreach Item Type [ eval <<FIELD>> = mvindex(Col2, mvfind(Col1, "<<FIELD>>*")) ]
| table which Type Item
0 Karma

to4kawa
Ultra Champion
| makeresults 
| eval _raw="Col1,Col2
Item_0,Monkey
Item_1,Tiger
Item_2 ,Gorilla
Type_0,1
Type_1,1
Type_2,0"
| multikv forceheader=1
| table Col1 Col2
| rex field=Col1 "(?<digit>\d)"
| stats values(*) as * by digit
| fields - digit
0 Karma
Get Updates on the Splunk Community!

Aligning Observability Costs with Business Value: Practical Strategies

 Join us for an engaging Tech Talk on Aligning Observability Costs with Business Value: Practical ...

Mastering Data Pipelines: Unlocking Value with Splunk

 In today's AI-driven world, organizations must balance the challenges of managing the explosion of data with ...

Splunk Up Your Game: Why It's Time to Embrace Python 3.9+ and OpenSSL 3.0

Did you know that for Splunk Enterprise 9.4, Python 3.9 is the default interpreter? This shift is not just a ...