Splunk Search

Appending a static lookup

ivan128
Explorer

Hi all,

I'm looking for a way to append the contents of a CSV table to any search I make as an additional column. For example I have the following search:

index=X  sourcetype=Y name=Z | dedup host-ip, plugin_name, plugin_family, severity, "ports{}.port", "ports{}.protocol" | chart count by host-ip

This gives me a table like this:

host-ip           count
1.1.1.1            3
2.2.2.2            4
3.3.3.3            7

I though that adding |inputlookup append=t testing.csv at the end of the search would add an additional column with the results from the lookup table but instead it adds them under the results from the search.

The contents of the CSV files are a list of IP addresses and I want a result that looks something like this:

host-ip           count    csvIP
1.1.1.1            3           1.1.1.1
2.2.2.2            4           2.2.2.2
3.3.3.3            7           3.3.3.3

Is there a command or parameter in the lookup command that can help me with this case?

Edit: Edited for clarity.

0 Karma

somesoni2
Revered Legend

The append command, as the name suggest, appends the result at the bottom of current result. Not sure what is your exact requirement, but you may want to use appendcols command. Would you mind showing what your final output should look like?

0 Karma

ivan128
Explorer

I edited the question for clarity. I looked up the appendcol command and it seems that it works with subsearches, so I'm not entirely sure how it would work with an inputlookup, I tried using:

index=X sourcetype=Y name=Z | dedup host-ip, plugin_name, plugin_family, severity, "ports{}.port", "ports{}.protocol" | chart count by host-ip| appendcols [inputlookup testing.csv]but it didn't work, it only presented me the original results, possibly I wrote something incorrecctly.

0 Karma
Get Updates on the Splunk Community!

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk on November 6 at 11AM PT, and empower your SOC to reach new heights! Duration: ...

Splunk Observability as Code: From Zero to Dashboard

For the details on what Self-Service Observability and Observability as Code is, we have some awesome content ...