Splunk Search

Can you help me with the following search using a lookup?

a212830
Champion

Hi,

We are frequently required to validate that data is being received by Splunk from multiple servers. The lists of IPs/hosts can be quite long. I am trying to come up with a search that will make this easier, like putting the entries into lookup files and then running a search against the entries in the lookups. So far, I have a lookup with a hostname, IP, and potentially, a wildcard for that host (sometimes the hosts are fully qualified and sometimes they are not). The IPs are reported as hosts, not as a separate "ip" field.

By using this search, I can retrieve data for hosts:

index=* [|inputlookup testSVB2.csv|table host ]

Is there anyway to expand this so it it will run a search against matching hosts OR IPs OR wildcards? When I table out host or IP, it seems to be running an "AND", rather than an "OR".

Finally, is there anyway to limit the number of events returned per host?

0 Karma
1 Solution

woodcock
Esteemed Legend

You need the format command; here is a run-anywhere example:

|makeresults | eval raw="host1,ip1 host2,ip2 host3,ip3"
| makemv raw
| mvexpand raw
| rename raw AS _raw
| rex "^(?<host>\w+),(?<ip>\w+)$"
| table host ip
| format "(" "(" "OR" ")" "OR" ")"

In your case, like this:

 index=* [|inputlookup testSVB2.csv | table host ip | format "(" "(" "OR" ")" "OR" ")"]

To limit the number of events per host just do this (I have chosen to limit to 10):

 index=* [|inputlookup testSVB2.csv | table host ip | format "(" "(" "OR" ")" "OR" ")"]
| dedup 10 host

View solution in original post

0 Karma

sloshburch
Splunk Employee
Splunk Employee

"We are frequently required to validate that data is being received by Splunk from multiple servers."
What about the Monitoring Console's page for Forwarders?

I use the alerts in MC as well to let me know of missing forwarders

0 Karma

woodcock
Esteemed Legend

You need the format command; here is a run-anywhere example:

|makeresults | eval raw="host1,ip1 host2,ip2 host3,ip3"
| makemv raw
| mvexpand raw
| rename raw AS _raw
| rex "^(?<host>\w+),(?<ip>\w+)$"
| table host ip
| format "(" "(" "OR" ")" "OR" ")"

In your case, like this:

 index=* [|inputlookup testSVB2.csv | table host ip | format "(" "(" "OR" ")" "OR" ")"]

To limit the number of events per host just do this (I have chosen to limit to 10):

 index=* [|inputlookup testSVB2.csv | table host ip | format "(" "(" "OR" ")" "OR" ")"]
| dedup 10 host
0 Karma

a212830
Champion

Thanks. These are both very good, it looks like woodcock's is more what I'm looking to implement. Is there anyway to limit the results per host? I tried "top limit=x", but that didn't work.

0 Karma

a212830
Champion

Figured it out. Add a "top limit=x host" to the end.

Also came up with a way to do the same thing via tstats, which is much faster.

Thanks!

0 Karma

Vijeta
Influencer

You can achieve that using map command
|inputlookup estSVB2.csv|fields host ip| map search="index=* host=$host$ OR ip=$ip$| table host ip"

0 Karma
Get Updates on the Splunk Community!

Splunk Observability Synthetic Monitoring - Resolved Incident on Detector Alerts

We’ve discovered a bug that affected the auto-clear of Synthetic Detectors in the Splunk Synthetic Monitoring ...

Video | Tom’s Smartness Journey Continues

Remember Splunk Community member Tom Kopchak? If you caught the first episode of our Smartness interview ...

3-2-1 Go! How Fast Can You Debug Microservices with Observability Cloud?

3-2-1 Go! How Fast Can You Debug Microservices with Observability Cloud? Learn how unique features like ...