Splunk Search

How do you compare a list of host names?

daniel333
Builder

All,

I have a list of X hosts and another list of Y hosts. Seems to be Splunk should have an easy way to diff these. Any special commands or tools?

0 Karma

macadminrohit
Contributor

You can very well do this by appending the both the lists and expand the appended list and then do a eventstats by appended list and finally see where the count < 2. Here is a sample search i wrote. Let me know if it works for you.

| makeresults | eval Data="Apple,Banana,Cat,Dog:Apple,Banana,Charlie,Daniel" | eval List1=mvindex(split(Data,":"),0) | eval List2=mvindex(split(Data,":"),1) | fields List1 List2 | makemv List1 Delim="," | makemv List2 Delim="," | eval List=mvappend(List1,List2) | mvexpand List | eventstats count by List | where count<2
0 Karma

richgalloway
SplunkTrust
SplunkTrust

The set command can show the differences between the two lists. It does not, however, tell you in which list the difference was found.

---
If this reply helps you, Karma would be appreciated.
0 Karma

nickhills
Ultra Champion

Do you mean lists (as in a CSV/lookup files) or do you mean a pair of queries which return you two different lists of host names?

If my comment helps, please give it a thumbs up!
0 Karma

daniel333
Builder

I can do either one. In this case I am comparing a CSV to a table I generate from logs.

0 Karma

macadminrohit
Contributor

can you try the solution i suggested below ?

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...