<?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: Can a search detect it's own sample ratio? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Can-a-search-detect-it-s-own-sample-ratio/m-p/312205#M161880</link>
    <description>&lt;P&gt;Well, I was really hoping for a hidden argument to &lt;CODE&gt;addinfo&lt;/CODE&gt; that would give it to me.  (Seems like the output of that command hasn't been updated since like the Splunk 3.x days, despite a massive increase in product functionality since then.)&lt;/P&gt;

&lt;P&gt;But that works assuming you don't end up with more than 1000 search jobs.  I'd probably add a &lt;CODE&gt;splunk_server=local&lt;/CODE&gt; to the rest command.&lt;/P&gt;</description>
    <pubDate>Wed, 04 Apr 2018 16:48:53 GMT</pubDate>
    <dc:creator>Lowell</dc:creator>
    <dc:date>2018-04-04T16:48:53Z</dc:date>
    <item>
      <title>Can a search detect it's own sample ratio?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-a-search-detect-it-s-own-sample-ratio/m-p/312203#M161878</link>
      <description>&lt;P&gt;Is there a way for a search to determine its own sample ratio at search time?&lt;/P&gt;

&lt;P&gt;This would be helpful when scaling results based on the sample ratio.  For example, if a &lt;CODE&gt;eventtype=myevent | stats count&lt;/CODE&gt; returns 57 at sample of 10:1, then I can estimate than a full search (no sample) would return a count of ~ 570.&lt;/P&gt;

&lt;P&gt;Seems like the should be away to do this with some combination of &lt;CODE&gt;addinfo&lt;/CODE&gt; and possibly &lt;CODE&gt;rest&lt;/CODE&gt;...?&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 21:36:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-a-search-detect-it-s-own-sample-ratio/m-p/312203#M161878</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2018-04-03T21:36:00Z</dc:date>
    </item>
    <item>
      <title>Re: Can a search detect it's own sample ratio?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-a-search-detect-it-s-own-sample-ratio/m-p/312204#M161879</link>
      <description>&lt;P&gt;Something like this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* 
    | addinfo 
    | stats values(info_sid) as sid 
    | join sid
        [| rest /services/search/jobs 
        | stats values(request.sample_ratio) AS request.sample_ratio by sid ]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Apr 2018 00:16:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-a-search-detect-it-s-own-sample-ratio/m-p/312204#M161879</guid>
      <dc:creator>jconger</dc:creator>
      <dc:date>2018-04-04T00:16:09Z</dc:date>
    </item>
    <item>
      <title>Re: Can a search detect it's own sample ratio?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-a-search-detect-it-s-own-sample-ratio/m-p/312205#M161880</link>
      <description>&lt;P&gt;Well, I was really hoping for a hidden argument to &lt;CODE&gt;addinfo&lt;/CODE&gt; that would give it to me.  (Seems like the output of that command hasn't been updated since like the Splunk 3.x days, despite a massive increase in product functionality since then.)&lt;/P&gt;

&lt;P&gt;But that works assuming you don't end up with more than 1000 search jobs.  I'd probably add a &lt;CODE&gt;splunk_server=local&lt;/CODE&gt; to the rest command.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Apr 2018 16:48:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-a-search-detect-it-s-own-sample-ratio/m-p/312205#M161880</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2018-04-04T16:48:53Z</dc:date>
    </item>
    <item>
      <title>Re: Can a search detect it's own sample ratio?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-a-search-detect-it-s-own-sample-ratio/m-p/312206#M161881</link>
      <description>&lt;P&gt;Here's an expanded example that approaches the problem in a slightly different way.  It only lookups up a single job via the REST request, but yet is has an extra subsearch (not sure the performance implications.) &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count 
| appendcols 
    [ rest splunk_server=local /services/search/jobs 
        [ makeresults 
        | addinfo 
        | eval sid=replace(info_sid, "^.*subsearch_(.*?\d+\.\d+)_.*$", "\1") 
        | eval search="search=sid=".sid 
        | table search ] 
    | table request.* ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note that the use of &lt;CODE&gt;appendcols&lt;/CODE&gt; requires results not events as an input.  (Think "Events" tab vs "Statistics" tab.)   It's also possible to use &lt;CODE&gt;append&lt;/CODE&gt; or (preferably) &lt;CODE&gt;appendpipe&lt;/CODE&gt; but then you'll only have a single result at the end that contains the &lt;CODE&gt;request.*&lt;/CODE&gt; fields, which is still workable in some situations, but a bit less ideal.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Apr 2018 16:59:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-a-search-detect-it-s-own-sample-ratio/m-p/312206#M161881</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2018-04-04T16:59:53Z</dc:date>
    </item>
  </channel>
</rss>

