Splunk Search

Splunk set diff

LordShacks
New Member

I am comparing the results of two search queries using "| set diff [search1][search2]". This works correctly in that I get all of the results that are either in search1 or search2 but not both.

I would like to be able to add additional fields to my searches without factoring them into the diff process. It seems like the diff command on it's own has this functionality if the "attribute=" keyword is used, which, if I understand correctly, limits the diff operation to the field specified.

However, it doesn't look like I can use the attribute keyword when diff is used in conjuction with set. Is there any way I can display additional fields without having diff operate on them?

Tags (2)
0 Karma

somesoni2
Revered Legend

I am not sure what you need is possible through with just "|set". Try this workaround to see if it gets you what you want.

index=index1 (sourcetype="souce1" gameStart="20140304-1500" ) OR (sourcetype="source2" gameStart="20140304-1600") [| set diff [search index="index1" sourcetype="souce1" gameStart="20140304-1500" | stats count by playerID | fields playerID] [search index="index1" sourcetype="source2" gameStart="20140304-1600" | stats count by playerId | fields playerID]]

LordShacks
New Member

So the first search is:

index="index1" sourcetype="souce1" gameStart="20140304-1500" | stats count by playerID | fields playerID

And the second is exactly the same, except with a different gameStart:

index="index1" sourcetype="source2" gameStart="20140304-1600" | stats count by playerId | fields playerID

Using these searches with "| set diff" I get the ID of all the players who played in the first game or the second game but not both.

However, in addition to the playerID, I want to display next to each ID the start time of the game that they played in.

0 Karma

gnovak
Builder

What is the search you are using?

0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...