<?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 Re: Working with Lookup in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Working-with-Lookup/m-p/293616#M88635</link>
    <description>&lt;P&gt;@Kwip, glad to hear that we were able to assist. Way to go with Automatic Lookup.&lt;/P&gt;

&lt;P&gt;Please Upvote the comments that helped and accept @adonio 's answer to mark this question as answered!&lt;/P&gt;</description>
    <pubDate>Tue, 04 Jul 2017 03:15:44 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2017-07-04T03:15:44Z</dc:date>
    <item>
      <title>Working with Lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Working-with-Lookup/m-p/293612#M88631</link>
      <description>&lt;P&gt;I am having below requirements to be merged to create a dashboard/Report.&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;Need to append my search result to the list of jobs in the look up table.
I am having look up table which contains list of jobs. I want to create a table which contains the list of jobs mentioned in my lookup along with its starting and end time. So I created something like this,
index=xxx sourcetype=yyy autosysjob=* [mylookup.csv] | stats latest(_time) as ActualEndTime, earliest(_time) as ActualStartTime, latest(Jobstatus) as CurrentStatus by autosysjob | sort by StartTime&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;The above query resulting in a table like below,&lt;BR /&gt;
autosysjob        -ActualStartTime                   -ActualEndTime                   -CurrentStatus&lt;BR /&gt;
Job1                   - 07/01/2017 10:51                - - 07/01/2017 10:55           -SUCCESS&lt;BR /&gt;
Job2                   - 07/01/2017 10:51                - - 07/01/2017 11:20           -RUNNING&lt;BR /&gt;
Job3                   - 07/01/2017 10:51                - - 07/01/2017 10:53           -SUCCESS&lt;/P&gt;

&lt;P&gt;I want to have two more field in this table&lt;BR /&gt;
The time mentioned in the above table is actual start and end time based on  the completion. I want have Expected start and end time (which is static value) in the above table. As mentioned below,&lt;/P&gt;

&lt;P&gt;autosysjob        -ExpectedStartTime    -ExpectedEndTime         -ActualStartTime         -ActualEndTime              CurrentStatus&lt;BR /&gt;
Job1                  - 07/01/2017 10:30        - 07/01/2017 10:55       - 07/01/2017 10:40     - - 07/01/2017 10:50     -SUCCESS&lt;BR /&gt;
Job2                   - 07/01/2017 10:50      - 07/01/2017 11:30        - 07/01/2017 10:51     - - 07/01/2017 11:10     -RUNNING&lt;BR /&gt;
Job3                   - 07/01/2017 09:00      - 07/01/2017 10:30        - 07/01/2017 09:00     - - 07/01/2017 10:15     -SUCCESS&lt;/P&gt;

&lt;P&gt;My next requirement is Adding one more field based on the Value of CurrentStatus field as mentioned below.&lt;/P&gt;

&lt;P&gt;autosysjob   -ExpectedStartTime    -ExpectedEndTime         -ActualStartTime         -ActualEndTime              CurrentStatus    -Action&lt;BR /&gt;
Job1               - 07/01/2017 10:30        - 07/01/2017 10:55       - 07/01/2017 10:40     - - 07/01/2017 10:50     -SUCCESS            - No&lt;BR /&gt;
Job2               - 07/01/2017 10:50      - 07/01/2017 11:30        - 07/01/2017 10:51     - - 07/01/2017 11:10     -RUNNING           - Monitor&lt;BR /&gt;
Job3               - 07/01/2017 09:00      - 07/01/2017 10:30        - 07/01/2017 09:00     - - 07/01/2017 10:15     -SUCCESS            - No&lt;BR /&gt;
Job4               - 07/01/2017 10:30        - 07/01/2017 10:55       - 07/01/2017 10:40     - - 07/01/2017 10:50     -FAILURE            - Critical&lt;BR /&gt;
Job5               - 07/01/2017 10:50      - 07/01/2017 11:30        - 07/01/2017 10:51     - - 07/01/2017 11:10     -RUNNING           - Monitor&lt;BR /&gt;
Job6               - 07/01/2017 09:00      - 07/01/2017 10:30        - 07/01/2017 09:00     - - 07/01/2017 10:15     -FAILURE              - Critical&lt;/P&gt;

&lt;P&gt;And the above is my final table. Please help me out to get it done. Thank in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:44:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Working-with-Lookup/m-p/293612#M88631</guid>
      <dc:creator>Kwip</dc:creator>
      <dc:date>2020-09-29T14:44:40Z</dc:date>
    </item>
    <item>
      <title>Re: Working with Lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Working-with-Lookup/m-p/293613#M88632</link>
      <description>&lt;P&gt;hello @Kwip,&lt;BR /&gt;
this is a partial answer as i am not 100% clear where in your data are the static values "ExpectedStartTime" and "ExpectedEndTime" ? are they in the lookup? are they tied to each "autosysjob" value or event?&lt;BR /&gt;
regarding your 2nd question, you can use &lt;CODE&gt;| eval case&lt;/CODE&gt; function. something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval Action = case(CurrentStatus="SUCCESS", "No", CurrentStatus="RUNNING", "Monitor", CurrentStatus="Failure", "Critical")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;hope it helps&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jul 2017 01:49:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Working-with-Lookup/m-p/293613#M88632</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2017-07-02T01:49:51Z</dc:date>
    </item>
    <item>
      <title>Re: Working with Lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Working-with-Lookup/m-p/293614#M88633</link>
      <description>&lt;P&gt;To add on to @adonio's comment, you need to provide more information for your lookup table, which is not clear from your first search (does not seem to be a working search based on syntax). What are the field names present in mylookup.csv?&lt;/P&gt;

&lt;P&gt;You would need to create Lookup definition of your lookup file (either Automatic or Manual based on your needs) using &lt;CODE&gt;Splunk &amp;gt; Settings &amp;gt; Lookup &amp;gt; Lookup definitions&lt;/CODE&gt;. Following example is assuming you have created manual Lookup Definition with name &lt;STRONG&gt;mylookup&lt;/STRONG&gt; (PS: grant proper access permissions otherwise search might not be able to find the lookup definition)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=xxx sourcetype=yyy [| inputlookup mylookup.csv | table autosysjob] 
| stats latest(_time) as ActualEndTime, earliest(_time) as ActualStartTime, latest(Jobstatus) as CurrentStatus by autosysjob 
| lookup  mylookup autosysjob output ExpectedStartTime, ExpectedEndTime 
| eval Action = case(CurrentStatus="SUCCESS", "No", CurrentStatus="RUNNING", "Monitor", CurrentStatus="Failure", "Critical",true(),"Monitor")
| sort - StartTime
| fieldformat ActualStartTime=strftime(ActualStartTime,"%m/%d/%Y %H:%M")
| fieldformat ActualEndTime=strftime(ActualEndTime,"%m/%d/%Y %H:%M")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Since you are generating ActualStartTime and ActualEndTime from _time field, it will be epoch time and you would need to apply fieldformat to display the same in human readable string time format. ExpectedStartTime and ExpectedEndTime do not need this conversion, since they are coming from lookup they will be string time and hence human readable.&lt;BR /&gt;
PS: I have added to default &lt;CODE&gt;true()&lt;/CODE&gt; condition to case statement to map all other Actions as "Monitor"&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jul 2017 05:57:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Working-with-Lookup/m-p/293614#M88633</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-07-02T05:57:07Z</dc:date>
    </item>
    <item>
      <title>Re: Working with Lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Working-with-Lookup/m-p/293615#M88634</link>
      <description>&lt;P&gt;Wow!!!! It did the tricks.!!!!!&lt;/P&gt;

&lt;P&gt;Thank you @niketnilay and @adonio&lt;/P&gt;

&lt;P&gt;@niketnilay - Though my question wasn't clear, your solution hit the bulls-eye. Just addition to your answer, I made lookup as automatic.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jul 2017 02:00:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Working-with-Lookup/m-p/293615#M88634</guid>
      <dc:creator>Kwip</dc:creator>
      <dc:date>2017-07-04T02:00:39Z</dc:date>
    </item>
    <item>
      <title>Re: Working with Lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Working-with-Lookup/m-p/293616#M88635</link>
      <description>&lt;P&gt;@Kwip, glad to hear that we were able to assist. Way to go with Automatic Lookup.&lt;/P&gt;

&lt;P&gt;Please Upvote the comments that helped and accept @adonio 's answer to mark this question as answered!&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jul 2017 03:15:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Working-with-Lookup/m-p/293616#M88635</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-07-04T03:15:44Z</dc:date>
    </item>
    <item>
      <title>Re: Working with Lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Working-with-Lookup/m-p/293617#M88636</link>
      <description>&lt;P&gt;done!!!!!!!&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jul 2017 04:06:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Working-with-Lookup/m-p/293617#M88636</guid>
      <dc:creator>Kwip</dc:creator>
      <dc:date>2017-07-04T04:06:01Z</dc:date>
    </item>
  </channel>
</rss>

