Splunk Search

Using Lookup Table

alan20854
Path Finder

Hi,

I am using a lookup table to populate 3 dropdown menus: Source, Service, and Method, where each selection of the previous dropdown creates the set of options for the next dropdown.

However, in the dropdown options for Service and Method, I am using a word description of the service/method code, e.g. Vendor Web Service in lieu of VNDR_WS. In my .csv file, the first three columns are source, service, and then method, and then I have two more columns with the corresponding serviceCode and methodCode.

How do I incorporate the last two columns into my search query? I would just like to search for something like serviceCode = $serviceCode$ methodCode=$methodCode$

0 Karma
1 Solution

somesoni2
Revered Legend

Use like this

dropdown service

<search>
     <query>| inputlookup Lookup.csv | search source="$source1$" | stats count by service serviceCode | table service serviceCode</query>
   </search>
   <fieldForLabel>service</fieldForLabel>
   <fieldForValue>serviceCode</fieldForValue>

dropdown method

 <search>
     <query>| inputlookup Lookup.csv | search (source = "$source1$" AND serviceCode = "$service1$")| stats count by method methodCode| table method methodCode</query>
     <earliest>0</earliest>
   </search>
   <fieldForLabel>method</fieldForLabel>
   <fieldForValue>methodCode</fieldForValue>

Panel Search

| inputlookup Lookup.csv | $serviceCode$ = search (source = "$source1$" AND serviceCode = "$service1$" AND methodCode = "$method1$") |sort -_time | head 1

View solution in original post

snoobzilla
Builder

Perfect used case for label/value functionality... I partially changed below. Basically you need to carry changes into your search.

 <input type="dropdown" token="source1" searchWhenChanged="true">
   <label>Source</label>
   <search>
     <query>| inputlookup Lookup.csv | stats count by source | table source</query>
   </search>
   <fieldForLabel>source</fieldForLabel>
   <fieldForValue>source</fieldForValue>
 </input>
 <input type="dropdown" token="service1" searchWhenChanged="true">
   <label>Service</label>
   <search>
     <query>| inputlookup Lookup.csv | search source="$source1$" | stats count by service | table service ServiceCode</query>
   </search>
   <fieldForLabel>service</fieldForLabel>
   <fieldForValue>ServiceCode</fieldForValue>
 </input>
 <input type="dropdown" token="method1" searchWhenChanged="true">
   <label>Method/Operation</label>
   <search>
     <query>| inputlookup Lookup.csv | search (source = "$source1$" AND service = "$service1$")| stats count by method | table method MethodCode</query>
     <earliest>0</earliest>
   </search>
   <fieldForLabel>method</fieldForLabel>
   <fieldForValue>MethodCode</fieldForValue>
 </input>
 <input type="time" token="time" searchWhenChanged="true">
   <label>Last Transaction Time</label>
   <default>
     <earliest>@d</earliest>
     <latest>now</latest>
   </default>
 </input>


 <panel>
   <event>
     <title>Most Recent Event</title>
     <search>
       <query>| inputlookup Lookup.csv | $serviceCode$ = search (source = "$source1$" AND service = "$service1$" AND method = "$method1$") |sort -_time | head 1
       <earliest>$time.earliest$</earliest>
       <latest>$time.latest$</latest>
     </search>
     <fields>["host","source","sourcetype"]</fields>
   </event>
 </panel>
0 Karma

somesoni2
Revered Legend

Use like this

dropdown service

<search>
     <query>| inputlookup Lookup.csv | search source="$source1$" | stats count by service serviceCode | table service serviceCode</query>
   </search>
   <fieldForLabel>service</fieldForLabel>
   <fieldForValue>serviceCode</fieldForValue>

dropdown method

 <search>
     <query>| inputlookup Lookup.csv | search (source = "$source1$" AND serviceCode = "$service1$")| stats count by method methodCode| table method methodCode</query>
     <earliest>0</earliest>
   </search>
   <fieldForLabel>method</fieldForLabel>
   <fieldForValue>methodCode</fieldForValue>

Panel Search

| inputlookup Lookup.csv | $serviceCode$ = search (source = "$source1$" AND serviceCode = "$service1$" AND methodCode = "$method1$") |sort -_time | head 1

alan20854
Path Finder

Thanks for the help!

0 Karma

snoobzilla
Builder

Yeah, what he said.

0 Karma

alan20854
Path Finder

Here is my XML:

<input type="dropdown" token="source1" searchWhenChanged="true">
  <label>Source</label>
  <search>
    <query>| inputlookup Lookup.csv | stats count by source | table source</query>
  </search>
  <fieldForLabel>source</fieldForLabel>
  <fieldForValue>source</fieldForValue>
</input>
<input type="dropdown" token="service1" searchWhenChanged="true">
  <label>Service</label>
  <search>
    <query>| inputlookup Lookup.csv | search source="$source1$" | stats count by service | table service</query>
  </search>
  <fieldForLabel>service</fieldForLabel>
  <fieldForValue>service</fieldForValue>
</input>
<input type="dropdown" token="method1" searchWhenChanged="true">
  <label>Method/Operation</label>
  <search>
    <query>| inputlookup Lookup.csv | search (source = "$source1$" AND service = "$service1$")| stats count by method | table method</query>
    <earliest>0</earliest>
  </search>
  <fieldForLabel>method</fieldForLabel>
  <fieldForValue>method</fieldForValue>
</input>
<input type="time" token="time" searchWhenChanged="true">
  <label>Last Transaction Time</label>
  <default>
    <earliest>@d</earliest>
    <latest>now</latest>
  </default>
</input>


<panel>
  <event>
    <title>Most Recent Event</title>
    <search>
      <query>| inputlookup Lookup.csv | $serviceCode$ = search (source = "$source1$" AND service = "$service1$" AND method = "$method1$") |sort -_time | head 1
      <earliest>$time.earliest$</earliest>
      <latest>$time.latest$</latest>
    </search>
    <fields>["host","source","sourcetype"]</fields>
  </event>
</panel>
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...