Splunk Search

Using Join to fields with another values

Astorn
Loves-to-Learn

I have lookup with possible sources and i'm comparing them with the real log events to check if any of them don't sending as expected. The hosts in lookup are without domain but the hosts in logs have added domain to the hostname. I want to join  both lookup and lists of sending hosts but i need that the command that will join superSide and superSide.computer.level.com as one hostname. I have found answers with the wild card but it seems not working, is there any other nice answer for this problem?

Labels (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

You could try stripping the domain from your host name before joining, but if I understand correctly, you just want the hosts which haven't got log entries, so, strip the domain name from your log host names, dedup by hostname, append your lookup data and count by hostname. Anything with a count of 1 will have come from your lookup, count of 2 appears in both your logs and your lookup. Is that what you are after?

0 Karma

Astorn
Loves-to-Learn

Thanks it is one possible solution, but it seems not very elegant, i'm looking for more modular way to do this. For example in some way it is not working,  i have many domains and may be in some case i want to have in register the hostname with some subdomains (part of all domain url). I will prefer modular solution when i can defined my own way to compare values to join.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

What do you mean by modular?

Also, please confirm that you want to find the hosts from your lookup that don't have recent log entries, or are you looking for something else?

0 Karma

Astorn
Loves-to-Learn

May be not modular but universal solution. My example:

in my logs i have: 

super-website.computer.pl

but in the register(excel ->lookup) i have

super-website 1.2.4.2.

But maybe it will not be enought and i will have  two

super-website.computer.pl

super-website.magic.pl

so will have to change register to have super-website.computer and another record super-website.magic.

I want to be able to join  the records base on the rule   record_from_log.domain="record_from_register*"to match based on wild card, i'm quite new in splunk search language so maybe my questions are not very precisly.

0 Karma

manjunathmeti
Champion

hi @Astorn,

You can strip domain name from host then do the lookup.

 

base_search 
| rex field=host "^(?<host_short>[^\.]+)"
| lookup lookup_name host AS host_short OUTPUT output_field

 

 

If this reply helps you, an upvote/like would be appreciated.

0 Karma

Astorn
Loves-to-Learn

OK it works but not exactly output as expected. I have sth like this in logs.

server.net1.com

server.net2.com

The hostname are the same the subdomain are other.

So i the register i have

server.net1

server.net2

Then the rex not working.

Is there a way to user regex to change server.net1  to be server.net1* and will join with server.net1.com

0 Karma

manjunathmeti
Champion

Check this site: https://splunkonbigdata.com/2020/08/04/handling-wildcard-characters-in-lookup-file/ . This should solve your problem. You should create csv file with field with wildcard values.

 

hostname, field1, field2
server.net1*, abc, xyz
server.net2*,abc,xyz

 

0 Karma

Astorn
Loves-to-Learn

Is there a way to add the * character to each host dynamicaly in search?

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...