Splunk Search

How to loop through results of a main inputlookup and combine with a child inputlookup?

erwin_pader_1dc
New Member

hi,

i have a main search-

|inputlookup wlaa_hosts.csv | eval Host=split(HostList,",") | stats count by Host

that results with-

Host           count
host1            1
host2            1
host3            1

i have another lookup that looks like-

MetricID                  AlertMsg
response_time             resp time > 10
error_count               error > 20

i want to loop through each of the host and attach it to every row in the child lookup, so that the result looks like-

Host     MetricID             AlertMsg
host1    response_time        resp time > 10
host1    error_count          error > 20
host2    response_time        resp time > 10
host2    error_count          error > 20

final step is to output each row to a KV Store lookup

i tried using the map command but it did not give me the desired result. appreciate very much for any help. thnx

0 Karma
1 Solution

somesoni2
SplunkTrust
SplunkTrust

Try like this

|inputlookup wlaa_hosts.csv | eval Host=split(HostList,",") | stats count by Host | join max=50 [| inputlookup secondlookup.csv | table MetricID AlertMsg ]

View solution in original post

0 Karma

somesoni2
SplunkTrust
SplunkTrust

Try like this

|inputlookup wlaa_hosts.csv | eval Host=split(HostList,",") | stats count by Host | join max=50 [| inputlookup secondlookup.csv | table MetricID AlertMsg ]
0 Karma

sundareshr
Legend

Try this

| inputlookup wlaa_hosts.csv | eval Host=split(HostList,",") | stats count by Host | inputlookup append=t secondfile.csv | fillnull Host value="settings" | eventstats values(if(eval(host="settings", MetricID, null()))) as MetricID values(if(eval(host="settings", AlertMsg, null()))) as AlertMsg by host | where Host!="settings" | eval z=mvzip(MetricID, AlertMsg, "#") | mvexpand z | rex field=z "(?<MetricID>[^#]+)#(?<AlertMsg>.+)" | fields - z
0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...