<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to use inputlookup and search together ? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-use-inputlookup-and-search-together/m-p/710746#M117389</link>
    <description>&lt;P&gt;HI Team&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to use the&amp;nbsp;inputlookup of csv file with 7 column and fill the details in those 7 columns using the search command that fetches the data from splunk ??&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Examples:&amp;nbsp;&lt;/P&gt;&lt;P&gt;My csv looks like this:&amp;nbsp;&lt;BR /&gt;Column1 , Column2&amp;nbsp;&lt;BR /&gt;Value A1 , Value B1&lt;BR /&gt;Value A2 , Value B2&lt;BR /&gt;Value A3 , Value B3&lt;BR /&gt;Value A4, Value B4&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I need output like below :&amp;nbsp;&lt;BR /&gt;Column1 , Column2 , Column3 , Column4&lt;BR /&gt;Value A1 , Value B1 , Value C1 , Value D1&lt;BR /&gt;Value A2 , Value B2&amp;nbsp;, Value C2 , Value D2&lt;BR /&gt;Value A3 , Value B3 , Value C3 , Value D3&lt;BR /&gt;Value A4, Value B4 , Value C4 , Value D4&lt;/P&gt;&lt;P&gt;Values of Column 3 and Column4 are fetched from Splunk using search command and using the key value of Column1.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I've tried to use the below search, but it is not working:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;| inputlookup File.csv&lt;BR /&gt;| join Column1 type=left&amp;nbsp;&lt;BR /&gt;[ | tstats&amp;nbsp;latest(Column3) as START_TIME ,&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;latest(Column4) as END_TIME&amp;nbsp;&lt;BR /&gt;where index = main source = xyz&amp;nbsp;&lt;BR /&gt;]&lt;BR /&gt;| table Column1 , Column2 , START_TIME , END_TIME&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Feb 2025 14:37:43 GMT</pubDate>
    <dc:creator>Real_captain</dc:creator>
    <dc:date>2025-02-05T14:37:43Z</dc:date>
    <item>
      <title>How to use inputlookup and search together ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-use-inputlookup-and-search-together/m-p/710746#M117389</link>
      <description>&lt;P&gt;HI Team&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to use the&amp;nbsp;inputlookup of csv file with 7 column and fill the details in those 7 columns using the search command that fetches the data from splunk ??&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Examples:&amp;nbsp;&lt;/P&gt;&lt;P&gt;My csv looks like this:&amp;nbsp;&lt;BR /&gt;Column1 , Column2&amp;nbsp;&lt;BR /&gt;Value A1 , Value B1&lt;BR /&gt;Value A2 , Value B2&lt;BR /&gt;Value A3 , Value B3&lt;BR /&gt;Value A4, Value B4&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I need output like below :&amp;nbsp;&lt;BR /&gt;Column1 , Column2 , Column3 , Column4&lt;BR /&gt;Value A1 , Value B1 , Value C1 , Value D1&lt;BR /&gt;Value A2 , Value B2&amp;nbsp;, Value C2 , Value D2&lt;BR /&gt;Value A3 , Value B3 , Value C3 , Value D3&lt;BR /&gt;Value A4, Value B4 , Value C4 , Value D4&lt;/P&gt;&lt;P&gt;Values of Column 3 and Column4 are fetched from Splunk using search command and using the key value of Column1.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I've tried to use the below search, but it is not working:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;| inputlookup File.csv&lt;BR /&gt;| join Column1 type=left&amp;nbsp;&lt;BR /&gt;[ | tstats&amp;nbsp;latest(Column3) as START_TIME ,&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;latest(Column4) as END_TIME&amp;nbsp;&lt;BR /&gt;where index = main source = xyz&amp;nbsp;&lt;BR /&gt;]&lt;BR /&gt;| table Column1 , Column2 , START_TIME , END_TIME&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 14:37:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-use-inputlookup-and-search-together/m-p/710746#M117389</guid>
      <dc:creator>Real_captain</dc:creator>
      <dc:date>2025-02-05T14:37:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to use inputlookup and search together ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-use-inputlookup-and-search-together/m-p/710786#M117400</link>
      <description>&lt;P&gt;Firstly join is almost never a solution to a Splunk problem.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Secondly, you do not have Column1 as an output of your tstats search, so how can it match up Col1+Col2 with the start/end times.&lt;/P&gt;&lt;P&gt;Generally if you want to enrich the start/end times with info from a lookup, you would run the tstats, then lookup the common fields (Column1)&amp;nbsp; from the lookup and output the other fields (Column2)&lt;/P&gt;&lt;P&gt;If you want to end up with all the rows from the lookup in the output, even where there is no data for some of the rows, you would then do a final couple of commands, i.e.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup File.csv append=t
| stats values(*) as * by Column1&lt;/LI-CODE&gt;&lt;P&gt;which would then give you all the rows from the lookup and start/end times from data for Column1 found in the tstats search.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2025 00:40:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-use-inputlookup-and-search-together/m-p/710786#M117400</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2025-02-06T00:40:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to use inputlookup and search together ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-use-inputlookup-and-search-together/m-p/710830#M117408</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp; for the suggestions.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Can you please let me know how i can use the lookup with the below search.&amp;nbsp;&lt;BR /&gt;Below query gives me the results of all the columns if there is a record in the splunk logs with JOBNAME values as A1 and A2.&amp;nbsp;&lt;BR /&gt;If there is no record for the jobname A1 and A2, there is no record fetched, and output is blank.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;index = main source=xyz&amp;nbsp; (TERM(A1) OR TERM(A2) )&amp;nbsp; &amp;nbsp;("- ENDED" OR "- STARTED"&amp;nbsp; )&lt;BR /&gt;| rex field=TEXT "((A1-) |(A2-) )(?&amp;lt;Func&amp;gt;[^\-]+)"&lt;BR /&gt;| eval Function=trim(Func), DAT = strftime(relative_time(_time, "+0h"), "%d/%m/%Y")&lt;BR /&gt;| rename DAT as Date_of_reception&lt;BR /&gt;| eval {Function}_TIME=_time&lt;BR /&gt;| stats values(Date_of_reception) as Date_of_reception values(*_TIME) as *_TIME by JOBNAME&lt;BR /&gt;| table JOBNAME,Description, Date_of_reception ,STARTED_TIME , ENDED_TIME&amp;nbsp;&lt;BR /&gt;| sort -STARTED_TIME&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We want the output as below even when there is no record in the splunk logs with&amp;nbsp;column1 values as A1 and A2.&lt;BR /&gt;When there is no record, fields "Date_of_reception ,STARTED_TIME , ENDED_TIME " should be Blank.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;File.csv :&lt;BR /&gt;JOBNAME&amp;nbsp;,Description&lt;BR /&gt;A1 , Job A1&lt;BR /&gt;A2, Job A2&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Desired Output :&amp;nbsp;&lt;BR /&gt;JOBNAME,Description, Date_of_reception ,STARTED_TIME , ENDED_TIME&lt;BR /&gt;A1 , Job A1 ,&amp;nbsp;05/02/2025 ,&amp;nbsp;12:54:31 ,&amp;nbsp;12:54:40&lt;BR /&gt;A2, Job A2&amp;nbsp;,&amp;nbsp;&amp;nbsp;,&amp;nbsp;&amp;nbsp;,&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Date_of_reception ,STARTED_TIME , ENDED_TIME is blank for A2 because there are no logs in Splunk for the Jobname A2.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Can you please help to update the query to get the desired output:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Current query:&amp;nbsp;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;index = main source=xyz&amp;nbsp; (TERM(A1) OR TERM(A2) )&amp;nbsp; &amp;nbsp;("- ENDED" OR "- STARTED"&amp;nbsp; )&lt;BR /&gt;| rex field=TEXT "((A1-) |(A2-) )(?&amp;lt;Func&amp;gt;[^\-]+)"&lt;BR /&gt;| eval Function=trim(Func), DAT = strftime(relative_time(_time, "+0h"), "%d/%m/%Y")&lt;BR /&gt;| rename DAT as Date_of_reception&lt;BR /&gt;| eval {Function}_TIME=_time&lt;BR /&gt;| stats values(Date_of_reception) as Date_of_reception values(*_TIME) as *_TIME by JOBNAME&lt;BR /&gt;| table JOBNAME,Description, Date_of_reception ,STARTED_TIME , ENDED_TIME&amp;nbsp;&lt;BR /&gt;| sort -STARTED_TIME&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2025 12:10:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-use-inputlookup-and-search-together/m-p/710830#M117408</guid>
      <dc:creator>Real_captain</dc:creator>
      <dc:date>2025-02-06T12:10:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to use inputlookup and search together ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-use-inputlookup-and-search-together/m-p/710874#M117414</link>
      <description>&lt;P&gt;So, you would use it like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index = main source=xyz  (TERM(A1) OR TERM(A2) )   ("- ENDED" OR "- STARTED"  )
| rex field=TEXT "((A1-) |(A2-) )(?&amp;lt;Func&amp;gt;[^\-]+)"
| eval Function=trim(Func), DAT = strftime(relative_time(_time, "+0h"), "%d/%m/%Y")
| rename DAT as Date_of_reception
| eval {Function}_TIME=_time
| stats values(Date_of_reception) as Date_of_reception values(*_TIME) as *_TIME by JOBNAME
``` This adds in all the entries in the lookup at the end of the current results ```
| inputlookup append=t File.csv
``` This then joins all the lookup fields to your result data based on JOBNAME ```
| stats values(*) as * by JOBNAME 
``` Now order the fields as needed and sort ```
| table JOBNAME Description Date_of_reception STARTED_TIME  ENDED_TIME 
| sort -STARTED_TIME&lt;/LI-CODE&gt;&lt;P&gt;i.e. append all the lookup data to the end and collapse it on JOBNAME&lt;/P&gt;&lt;P&gt;Note that your _time handling is a little strange - not sure what you're trying to do, but what's wrong with just&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval DATE_of_reception=strftime(_time, "%d/%m/%Y")&lt;/LI-CODE&gt;&lt;P&gt;Note also that if you have more than 1 START_TIME or END_TIME, the sort will not work correctly on the multivalue field.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2025 22:14:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-use-inputlookup-and-search-together/m-p/710874#M117414</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2025-02-06T22:14:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to use inputlookup and search together ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-use-inputlookup-and-search-together/m-p/710910#M117421</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp; , it worked for me.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another question,&amp;nbsp;&lt;BR /&gt;Is it possible to fetch only the latest record with latest &lt;SPAN&gt;END_TIME&amp;nbsp;&lt;/SPAN&gt;when we have multiple records with different&amp;nbsp;&lt;SPAN&gt;END_TIME.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Currently, if there are 2 records with the different&amp;nbsp;END_TIME for the same JOBNAME, we have 2 records.&amp;nbsp;&lt;BR /&gt;Is it possible to display only 1 record per jobname with the latest&amp;nbsp;END_TIME ??&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2025 11:56:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-use-inputlookup-and-search-together/m-p/710910#M117421</guid>
      <dc:creator>Real_captain</dc:creator>
      <dc:date>2025-02-07T11:56:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to use inputlookup and search together ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-use-inputlookup-and-search-together/m-p/711061#M117454</link>
      <description>&lt;P&gt;I am not sure how you would get two 'records' for the same jobname as all the aggregations you are doing are&amp;nbsp;&lt;STRONG&gt;by JOBNAME&lt;/STRONG&gt;. But do you mean you have two (or more) values of END_TIME for the same single JOBNAME in the output.&lt;/P&gt;&lt;P&gt;That would be because you are doing&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats values(Date_of_reception) as Date_of_reception values(*_TIME) as *_TIME by JOBNAME&lt;/LI-CODE&gt;&lt;P&gt;i.e. values(*_TIME)... is giving you all the values of the START and END TIME values.&lt;/P&gt;&lt;P&gt;If you just want the latest END_TIME then you just need to use max and min as needed, i.e.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats values(Date_of_reception) as Date_of_reception max(END_TIME) as END_TIME min(START_TIME) as START_TIME by JOBNAME&lt;/LI-CODE&gt;&lt;P&gt;would give you the earliest start and the latest end.&lt;/P&gt;&lt;P&gt;But if you have getting more than one event then any use of values will give you all values, but note also that values() will sort the values in the multivalue field, so bear that in mind.&lt;/P&gt;</description>
      <pubDate>Sun, 09 Feb 2025 21:32:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-use-inputlookup-and-search-together/m-p/711061#M117454</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2025-02-09T21:32:04Z</dc:date>
    </item>
  </channel>
</rss>

