Splunk Search

Union of two fields

mohitab
Path Finder

I have a query that produces results that has two columns :

| field1 | field2 | 

Field1 & Field2 have same domain, i.e. takes same set of values. I need to find out Union of the distinct values from both fields.

Any ideas?

Tags (2)
0 Karma
1 Solution

aweitzman
Motivator

Something like this:

...your search...
| stats values(field1) as f1values values(field2) as f2values 
| eval allvalues=mvdedup(mvappend(f1values,f2values))

ought to work.

View solution in original post

btt
Path Finder

HI
I propose this

Index=…  field1=*|table field1|append[search  index=…  field2=*|table field2]| eval allvalues=mvappend(field1,field2)|dedup allvalues |table field1 field2 allvalues |sort allvalues
0 Karma

richgalloway
SplunkTrust
SplunkTrust

It's not clear what you want the output to be. This will show all the combinations of field1 and field2 in your data.

<your search> | dedup field1 field2 | ...
---
If this reply helps you, Karma would be appreciated.
0 Karma

aweitzman
Motivator

Something like this:

...your search...
| stats values(field1) as f1values values(field2) as f2values 
| eval allvalues=mvdedup(mvappend(f1values,f2values))

ought to work.

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 ...