Splunk Search

Check field against two lookup tables

Path Finder

I have two lookup tables that may contain the hostname of an IP address

| lookup cmdb_ci_server_lookup ip_address as src output fqdn as orig_host
| lookup lansweeper_assets_lookup IPAddress as src output AssetName as orig_host

However, if AssetName in lansweeper_assets_lookup is null, the output of orig_host will be null as well. I know I can assign them different names and do an eval to combine but was hoping to get a more elegant way. any ideas?

0 Karma
1 Solution

Path Finder

thanks but this is basically what I had and it's super long. outputnew did the trick!

View solution in original post

0 Karma

Path Finder

thanks but this is basically what I had and it's super long. outputnew did the trick!

View solution in original post

0 Karma

Esteemed Legend

Click Accept on your answer and the UpVote anything else that was useful.

0 Karma

Super Champion

If you're just trying to bring in hostname and not combine the tables together, I'd use coalesce. I'd just do something like

|join src type=left [|inputlookup cmdb_ci_server_lookup|fields ip_address fqdn|rename ip_address as src] 
|join src type=left [|inputlookup lansweeper_assets_lookup |fields IPAddress AssetName|rename IPAddress as src]
|eval orig_host=coalesce(fqdn,AssetName)
0 Karma

Revered Legend

Which value takes precedence, once from lansweeper_assets_lookup OR one from cmdb_ci_server_lookup (assuming both returns value)?

0 Karma

Path Finder

both should have the same data, so it doesn't really matter to me. but sometimes one is null and the other isn't

0 Karma

Revered Legend

Cool. So in your lookup command, you're using OUTPUT option to get orig_host, replace it with OUTPUTNEW.

If the OUTPUT clause is specified, the output lookup fields overwrite existing fields. If the OUTPUTNEW clause is specified, the lookup is not performed for events in which the output fields already exist.

So your queries will be like this

| lookup cmdb_ci_server_lookup ip_address as src outputnew fqdn as orig_host
| lookup lansweeper_assets_lookup IPAddress as src outputnew AssetName as orig_host

Path Finder

ah! totally forgot about outputnew instead of output.

0 Karma

Super Champion

what exactly is the goal? to join cmdb_ci_server_lookup to lansweeper_assets_lookup by ip_address/IPAddress and fill the null values of AssetName/orig_host from lansweeper_assets_lookup?

0 Karma

Path Finder

the goal is to get the hostname from either lookup table. not looking to combine them, although maybe I should just do that in a different search

0 Karma