<?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: Alternatives to Lookup in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Alternatives-to-Lookup/m-p/386102#M112714</link>
    <description>&lt;P&gt;Assuming that file that contains hours charged is a lookup table file and you're using &lt;CODE&gt;| lookup yourlookupname.csv..&lt;/CODE&gt; to do the lookup, that should be fastest way. &lt;/P&gt;</description>
    <pubDate>Wed, 09 May 2018 16:27:28 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2018-05-09T16:27:28Z</dc:date>
    <item>
      <title>Alternatives to Lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Alternatives-to-Lookup/m-p/386100#M112712</link>
      <description>&lt;P&gt;Everyone,&lt;/P&gt;

&lt;P&gt;The events on splunk for me have data in the following format : &lt;/P&gt;

&lt;P&gt;ticket_num,actual_start_time,finish_time,assigned_to. &lt;/P&gt;

&lt;P&gt;For Example : &lt;/P&gt;

&lt;P&gt;A particular ticket number IN1234 has a start time of "January 1 2018" and finish time of "January 5 2018" along with whom the ticket was assigned to, for example, "A". This particular ticket may have been worked by "A" and also by "B" and "C". "A" might have charged 5 hours to the ticket, "B" - 3 hours and "C" - 2 hours. &lt;/P&gt;

&lt;P&gt;The file consisting of the hours charged by "A","B" and "C" is in the format of : &lt;/P&gt;

&lt;P&gt;"Resource Name","Date Charged in mm/dd/yyyy" ,"Hours Charged","Ticket Number"&lt;/P&gt;

&lt;P&gt;"A",01/02/2018,5,IN1234&lt;BR /&gt;
"B",01/04/2018,3,IN1234&lt;BR /&gt;
"C",01/05/2018,2,IN1234&lt;/P&gt;

&lt;P&gt;The current approach I am following to utilize the hours charged values is to : &lt;/P&gt;

&lt;P&gt;1) Since IN1234 is only going to be present once in the indexed data (one event); I use the ticket_num to lookup with the file mentioned above. &lt;BR /&gt;
2) I get a multivalued field like below : &lt;/P&gt;

&lt;P&gt;| table ticket_num name date_charged effort&lt;/P&gt;

&lt;P&gt;IN1234 "A"  01/02/2018 &lt;STRONG&gt;5&lt;/STRONG&gt;&lt;BR /&gt;
              "B"  01/04/2018 &lt;STRONG&gt;3&lt;/STRONG&gt;&lt;BR /&gt;
              "C"  01/05/2018 &lt;STRONG&gt;2&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;3) I do an mvzip --&amp;gt; | eval Test = mvzip(name,date_charged) --&amp;gt; &lt;BR /&gt;
"A",01/02/2018&lt;BR /&gt;
"B",01/04/2018&lt;BR /&gt;
"C",01/05/2018&lt;/P&gt;

&lt;P&gt;4) I do another mvzip -- | eval Test = mvzip(Test,effort) --&amp;gt; &lt;BR /&gt;
"A",01/02/2018,5&lt;BR /&gt;
"B",01/04/2018,3&lt;BR /&gt;
"C",01/05/2018,2&lt;/P&gt;

&lt;P&gt;5) I do a mvexpand on Test, so now I have 3 events like the following &lt;/P&gt;

&lt;P&gt;|table ticket_num Test&lt;BR /&gt;
IN1234 "A",01/02/2018,5&lt;BR /&gt;
IN1234 "B",01/04/2018,3&lt;BR /&gt;
IN1234 "C",01/05/2018,2&lt;/P&gt;

&lt;P&gt;6) I use Split on Test and use mvindex to assign values &lt;BR /&gt;
| eval Split = split(Test,",")&lt;BR /&gt;
| eval name = mvindex(Split,0)&lt;BR /&gt;
| eval date_charged = mvindex(Split,1)&lt;BR /&gt;
| eval effort = mvindex(Split,2)&lt;/P&gt;

&lt;P&gt;Using the above I can now use the data I retrieved from the lookup. &lt;/P&gt;

&lt;P&gt;I wanted to know if there was a better alternative for the "Lookup" approach used above as there are many restrictions to this method, slower searches with an increase in tickets being one of them. &lt;/P&gt;

&lt;P&gt;Let me know. &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:26:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Alternatives-to-Lookup/m-p/386100#M112712</guid>
      <dc:creator>aamirs291</dc:creator>
      <dc:date>2020-09-29T19:26:58Z</dc:date>
    </item>
    <item>
      <title>Re: Alternatives to Lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Alternatives-to-Lookup/m-p/386101#M112713</link>
      <description>&lt;P&gt;There is a more efficient way to breakout data after the &lt;CODE&gt;mvexpand&lt;/CODE&gt; but you have the right ideas.  I would do it like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults | eval _raw="01/02/2018 01/04/2018 01/05/2018,A B C,5 3 2"
| eval tikcet_num="IN1234"
| rex "^(?&amp;lt;date_changed&amp;gt;[^,]+),(?&amp;lt;name&amp;gt;[^,]+),(?&amp;lt;effort&amp;gt;[^,]+)$"
| makemv name
| makemv date_changed
| makemv effort
| fields - _*

| rename COMMENT AS "Everything above generates sample event data;everything below is your solution)"

| eval raw=mvzip(mvzip(date_changed, name), effort)
| table tikcet_num raw
| mvexpand raw
| rename raw AS _raw
| rex "^(?&amp;lt;date_changed&amp;gt;[^,]+),(?&amp;lt;name&amp;gt;[^,]+),(?&amp;lt;effort&amp;gt;[^,]+)$"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 May 2018 15:33:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Alternatives-to-Lookup/m-p/386101#M112713</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2018-05-09T15:33:11Z</dc:date>
    </item>
    <item>
      <title>Re: Alternatives to Lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Alternatives-to-Lookup/m-p/386102#M112714</link>
      <description>&lt;P&gt;Assuming that file that contains hours charged is a lookup table file and you're using &lt;CODE&gt;| lookup yourlookupname.csv..&lt;/CODE&gt; to do the lookup, that should be fastest way. &lt;/P&gt;</description>
      <pubDate>Wed, 09 May 2018 16:27:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Alternatives-to-Lookup/m-p/386102#M112714</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-05-09T16:27:28Z</dc:date>
    </item>
    <item>
      <title>Re: Alternatives to Lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Alternatives-to-Lookup/m-p/386103#M112715</link>
      <description>&lt;P&gt;Thank you somesoni2. Yes the hours charged are in a lookup table. &lt;/P&gt;

&lt;P&gt;Just to clarify I wanted to know if there was any other way to accomplish what I am doing above, but without using lookups. If there isnt then I will stick to this approach. &lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2018 10:12:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Alternatives-to-Lookup/m-p/386103#M112715</guid>
      <dc:creator>aamirs291</dc:creator>
      <dc:date>2018-05-10T10:12:09Z</dc:date>
    </item>
    <item>
      <title>Re: Alternatives to Lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Alternatives-to-Lookup/m-p/386104#M112716</link>
      <description>&lt;P&gt;Thank you woodcock.&lt;/P&gt;

&lt;P&gt;There seems to be slight improvement in speed when I use rex instead of split. I think I will use rex since you would need to write lesser code. &lt;/P&gt;

&lt;P&gt;As mentioned in my comment to somesoni2, for the scenario mentioned above is retrieving data from the lookup table the fastest way ? Let me know. &lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2018 10:15:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Alternatives-to-Lookup/m-p/386104#M112716</guid>
      <dc:creator>aamirs291</dc:creator>
      <dc:date>2018-05-10T10:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: Alternatives to Lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Alternatives-to-Lookup/m-p/386105#M112717</link>
      <description>&lt;P&gt;You could index the events and pull from a search, but if your data is correct in the lookups, I'd keep it that way. &lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2018 14:27:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Alternatives-to-Lookup/m-p/386105#M112717</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2018-05-10T14:27:44Z</dc:date>
    </item>
  </channel>
</rss>

