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!

Mastering Threat Intelligence in ES 8.5, Splunk AI Assistant v2, and More from Splunk ...

Splunk Lantern is Splunk’s customer success center that provides practical guidance from Splunk experts on key ...

Break the Build: Inside the KubeDoom Lounge at .conf26

    You step up to the machine. The pixelated corridors of a certain 1993 FPS load in front of you, EMP Pulse ...

Splunk Auto Ingestion Parallel Pipeline Scaling

Why this feature matters Many Splunk environments experience ingestion pressure long before the host is fully ...