<?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: How to search in scheduled report in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-in-scheduled-report/m-p/367194#M174540</link>
    <description>&lt;P&gt;Thanks for the quick answer but I don't think it applicable in this case.&lt;/P&gt;

&lt;P&gt;Indeed my subsearch is a database request (dbxquery). The DB request is only returning 10 lines. The map function takes a lot of time because the request is executed for each event. This is why I want to reuse the results of the scheduled report.&lt;/P&gt;</description>
    <pubDate>Wed, 21 Jun 2017 09:23:29 GMT</pubDate>
    <dc:creator>PaulDelcorde</dc:creator>
    <dc:date>2017-06-21T09:23:29Z</dc:date>
    <item>
      <title>How to search in scheduled report</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-in-scheduled-report/m-p/367192#M174538</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Is it possible to search in a scheduled report?&lt;BR /&gt;
I scheduled a request in a report because this request takes some time to execute. Then I would like to use the result of the scheduled request in other requests.&lt;/P&gt;

&lt;P&gt;I am using the map function in my request, that's why i am interested of using the result of a scheduled request (for performance issue).&lt;/P&gt;

&lt;P&gt;In the main request i am searching my logs, for each one of them I have a user identifier: &lt;EM&gt;sponsor_imsi&lt;/EM&gt;. But I need to find to which customer belongs this user. Each customer has a range of id, so in need to find the customer where the &lt;EM&gt;sponsor_imsi&lt;/EM&gt; is included in the range.&lt;/P&gt;

&lt;P&gt;Here is my request:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=pbx billing_duration="*" | table _time Date Application msisdn mvno_imsi sponsor_imsi
   | map maxsearches=50000 search="| from datamodel:CustomerRange | search RangeStart&amp;lt;=$sponsor_imsi$ RangeEnd&amp;gt;=$sponsor_imsi$ | eval sponsor_imsi=$sponsor_imsi$"
| table Allocation RangeStart RangeEnd sponsor_imsi msisdn 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So far I managed to use the a datamodel (CustomerRange) for the subsearch in the map function. But i cannot find a way to search in scheduled report instead.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2017 09:02:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-in-scheduled-report/m-p/367192#M174538</guid>
      <dc:creator>PaulDelcorde</dc:creator>
      <dc:date>2017-06-21T09:02:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to search in scheduled report</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-in-scheduled-report/m-p/367193#M174539</link>
      <description>&lt;P&gt;You can enable summary indexing for the search and then search the results in the summary index.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2017 09:06:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-in-scheduled-report/m-p/367193#M174539</guid>
      <dc:creator>dineshraj9</dc:creator>
      <dc:date>2017-06-21T09:06:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to search in scheduled report</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-in-scheduled-report/m-p/367194#M174540</link>
      <description>&lt;P&gt;Thanks for the quick answer but I don't think it applicable in this case.&lt;/P&gt;

&lt;P&gt;Indeed my subsearch is a database request (dbxquery). The DB request is only returning 10 lines. The map function takes a lot of time because the request is executed for each event. This is why I want to reuse the results of the scheduled report.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2017 09:23:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-in-scheduled-report/m-p/367194#M174540</guid>
      <dc:creator>PaulDelcorde</dc:creator>
      <dc:date>2017-06-21T09:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to search in scheduled report</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-in-scheduled-report/m-p/367195#M174541</link>
      <description>&lt;P&gt;so i have a similar problem (if i understand correctly) that i work around with rest. below is a rough sketch of what i do. I grab the results of my saved search using the rest command (a lot of it can probably get stripped out or made more efficient, it was a first run effort). Then I count by label (which is the name of my saved search) and i then map all of the results of those saved searches together. after that i do a bunch of stats/evals to join them all.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|rest /services/search/jobs|search isSaved=1 isSavedSearch=1 author=cmerrima isDone=1 delegate="scheduler" label="Scheduled Search Name"|stats count by label|fields - count|map maxsearches=10000 search="loadjob savedsearch="cmerrima:search:$label$""
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;i think you could do something similar if you have a saved search for the first part and map it to the datamodel.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2017 11:46:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-in-scheduled-report/m-p/367195#M174541</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2017-06-21T11:46:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to search in scheduled report</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-in-scheduled-report/m-p/367196#M174542</link>
      <description>&lt;P&gt;To get the results of a scheduled report you use &lt;CODE&gt;loadjob&lt;/CODE&gt;:&lt;BR /&gt;
&lt;A href="https://docs.splunk.com/Documentation/SplunkCloud/6.6.0/SearchReference/Loadjob"&gt;https://docs.splunk.com/Documentation/SplunkCloud/6.6.0/SearchReference/Loadjob&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2017 14:49:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-in-scheduled-report/m-p/367196#M174542</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-06-21T14:49:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to search in scheduled report</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-in-scheduled-report/m-p/367197#M174543</link>
      <description>&lt;P&gt;Hi, I moved the rant-mode comments to the bottom, and left them for the amusement of fellow senior splunkers.  Here's the kind and gentle version:&lt;/P&gt;

&lt;P&gt;There are a couple of dozen better ways to do this.   This is just one.  This should run about a half zillion times faster than using &lt;CODE&gt;map&lt;/CODE&gt;.  &lt;/P&gt;

&lt;P&gt;I'm going to assume you can get a record that looks like this ( &lt;CODE&gt;| table customer RangeStart RangeEnd&lt;/CODE&gt;) out of your data model with one record per customer, including their start and end of imsi range.     You can do that with a subsearch, or you could just create a csv file with the information and use &lt;CODE&gt;| inputcsv&lt;/CODE&gt;. &lt;/P&gt;

&lt;P&gt;Insert that &lt;CODE&gt;search&lt;/CODE&gt; or &lt;CODE&gt;inputcsv&lt;/CODE&gt; where all the asterisks &lt;CODE&gt;*********&amp;gt;&lt;/CODE&gt;  are.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=pbx billing_duration="*" 
| table _time Date Application msisdn mvno_imsi sponsor_imsi
| eval sortorder="B"
| rename COMMENT as "The above takes your records and puts them by sponsor_imsi in the middle of the sort order" 

| rename COMMENT as "The following takes your beginning and ending sponsor_imsi records into the mix, having the customer number start on the A record."
| rename COMMENT as "The Z end-of-range record blanks out the customer number for all following records in case an invalid imsi does not fit a range."
    [ your search that gets *********&amp;gt;  | table customer RangeStart RangeEnd
      | eval sortorder=mvappend("A","Y","Z")
      | mvexpand sortorder
      | eval sponsor_imsi = if(sortorder="A",RangeStart,RangeEnd)
      | eval customer=if(sortorder="Z","((unknown))",customer)
      | table customer sponsor_imsi sortorder
    ]

| rename COMMENT as "Now we sort the records into imsi order, and take the most recent customer for each imsi." 
| sort 0 sponsor_imsi sortorder
| streamstats current=t last(customer) as customer  

| rename COMMENT as "Finally, we kill all records that are not from the original search, and set customer to ((unknown)) if the imsi was below the lowest valid range." 
| where   sortorder=="B"
| fillnull value="((unknown))" customer 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;(Rant mode ON) &lt;/P&gt;

&lt;P&gt;Okay, NO.  No No No.  &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;Map&lt;/CODE&gt; should be avoided whenever possible.  This use of &lt;CODE&gt;map&lt;/CODE&gt; is ... completely avoidable.  In a hundred ways you can do this, &lt;CODE&gt;map&lt;/CODE&gt; might work, but is arguably the very worst option.  Calling a search 50K times sequentially? NO.&lt;/P&gt;

&lt;P&gt;Have I mentioned, NO?&lt;/P&gt;

&lt;P&gt;(/Rant mode OFF)&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2017 17:23:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-in-scheduled-report/m-p/367197#M174543</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-06-21T17:23:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to search in scheduled report</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-in-scheduled-report/m-p/367198#M174544</link>
      <description>&lt;P&gt;Thanks for the answer.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2017 17:35:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-in-scheduled-report/m-p/367198#M174544</guid>
      <dc:creator>PaulDelcorde</dc:creator>
      <dc:date>2017-06-21T17:35:47Z</dc:date>
    </item>
  </channel>
</rss>

