<?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: Pass field into a subsearch from stats command in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Pass-field-into-a-subsearch-from-stats-command/m-p/538571#M152273</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks. In the end i used a nested search to extract the name using the binary NOT NULL, then passed this through to the main search.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
    <pubDate>Thu, 04 Feb 2021 08:56:46 GMT</pubDate>
    <dc:creator>ssaenger</dc:creator>
    <dc:date>2021-02-04T08:56:46Z</dc:date>
    <item>
      <title>Pass field into a subsearch from stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pass-field-into-a-subsearch-from-stats-command/m-p/538081#M152099</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have data&lt;/P&gt;&lt;TABLE border="1" width="56.25%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="25%"&gt;name&lt;/TD&gt;&lt;TD width="25%"&gt;binary&lt;/TD&gt;&lt;TD width="25%"&gt;keynumber&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%"&gt;Steve&lt;/TD&gt;&lt;TD width="25%"&gt;1100&lt;/TD&gt;&lt;TD width="25%"&gt;12345&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%"&gt;Steve&lt;/TD&gt;&lt;TD width="25%"&gt;100&lt;/TD&gt;&lt;TD width="25%"&gt;13246&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%"&gt;Steve&lt;/TD&gt;&lt;TD width="25%"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="25%"&gt;12347&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%"&gt;Charles&lt;/TD&gt;&lt;TD width="25%"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="25%"&gt;23456&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to count the whether the position in the binary from right to left has a 1 in position 3 and 4 and as a percentage of the number of events.&lt;/P&gt;&lt;P&gt;eg result&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="20%" height="25px"&gt;name&lt;/TD&gt;&lt;TD width="20%" height="25px"&gt;events&lt;/TD&gt;&lt;TD width="20%" height="25px"&gt;4thbinary&lt;/TD&gt;&lt;TD width="20%" height="25px"&gt;3rdbinary&lt;/TD&gt;&lt;TD width="10%" height="25px"&gt;%4th&lt;/TD&gt;&lt;TD width="10%"&gt;%3rd&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="20%" height="25px"&gt;Steve&lt;/TD&gt;&lt;TD width="20%" height="25px"&gt;3&lt;/TD&gt;&lt;TD width="20%" height="25px"&gt;1&lt;/TD&gt;&lt;TD width="20%" height="25px"&gt;2&lt;/TD&gt;&lt;TD width="10%" height="25px"&gt;33&lt;/TD&gt;&lt;TD width="10%"&gt;66&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i was trying to get the 4 position first as this will give me the Names with a binary entry, i then thought i could join and run a subsearch to get the all the events, i then wold do an appendcols to get entries with a 1 in the 3rd binary position in the string.&lt;/P&gt;&lt;P&gt;index=summary sourcetype=prod source=service binary NOT NULL&amp;nbsp;&lt;BR /&gt;|eval red=substr(binary, -4, 1) |stats count(red) AS red by name&lt;/P&gt;&lt;P&gt;| join type=left name [search index=summary sourcetype=prod source=service&lt;BR /&gt;| dedup name keynumber&lt;BR /&gt;|stats count(keynumber) AS Events by name]&lt;/P&gt;&lt;P&gt;|appendcols [search&amp;nbsp;index=summary sourcetype=prod source=service binary NOT NULL&amp;nbsp;&lt;BR /&gt;|eval blue=substr(binary, -3, 1) |stats count(blue) AS blue by name]&lt;/P&gt;&lt;P&gt;|table name events red blue&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;however i cannot get my events to equal the correct value, it only returns a value if the binary field is populated.&lt;/P&gt;&lt;P&gt;i have looked at map and field but could also not get these to work.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Feb 2021 13:07:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pass-field-into-a-subsearch-from-stats-command/m-p/538081#M152099</guid>
      <dc:creator>ssaenger</dc:creator>
      <dc:date>2021-02-01T13:07:37Z</dc:date>
    </item>
    <item>
      <title>Re: Pass field into a subsearch from stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pass-field-into-a-subsearch-from-stats-command/m-p/538115#M152109</link>
      <description>&lt;P&gt;Try something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=summary sourcetype=prod source=service
| eval red=substr(binary, -4, 1)
| eval blue=substr(binary, -3, 1)
| fillnull value=0 red blue
| stats sum(red) AS red sum(blue) as blue by name&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 01 Feb 2021 16:10:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pass-field-into-a-subsearch-from-stats-command/m-p/538115#M152109</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-02-01T16:10:43Z</dc:date>
    </item>
    <item>
      <title>Re: Pass field into a subsearch from stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pass-field-into-a-subsearch-from-stats-command/m-p/538252#M152133</link>
      <description>&lt;P&gt;Hi ITWhisperer,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks, based on this i have added&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats sum(red) AS red sum(blue) as blue count(keynumber) as events by name&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However i also get the name charles returned.&lt;/P&gt;&lt;P&gt;How would i only get the name Steve returned as per the results table above?&lt;/P&gt;&lt;P&gt;i did try&amp;nbsp;&lt;BR /&gt;binary not null&lt;/P&gt;&lt;P&gt;however, i loose the line with key number 12347 -&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Feb 2021 09:54:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pass-field-into-a-subsearch-from-stats-command/m-p/538252#M152133</guid>
      <dc:creator>ssaenger</dc:creator>
      <dc:date>2021-02-02T09:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: Pass field into a subsearch from stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pass-field-into-a-subsearch-from-stats-command/m-p/538308#M152152</link>
      <description>&lt;P&gt;What criteria do you use to decide whether to keep Charles or Steve?&lt;/P&gt;</description>
      <pubDate>Tue, 02 Feb 2021 17:00:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pass-field-into-a-subsearch-from-stats-command/m-p/538308#M152152</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-02-02T17:00:04Z</dc:date>
    </item>
    <item>
      <title>Re: Pass field into a subsearch from stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pass-field-into-a-subsearch-from-stats-command/m-p/538397#M152195</link>
      <description>&lt;P&gt;i was using the criteria&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;binary not null&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;so this will give me the entries for steve.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;However from this i then want the total number of entries for Steve.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This is why i initially thought i would need to use a join, as i would pass the name field&amp;nbsp; in order to get the total number of fields.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 09:39:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pass-field-into-a-subsearch-from-stats-command/m-p/538397#M152195</guid>
      <dc:creator>ssaenger</dc:creator>
      <dc:date>2021-02-03T09:39:48Z</dc:date>
    </item>
    <item>
      <title>Re: Pass field into a subsearch from stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pass-field-into-a-subsearch-from-stats-command/m-p/538398#M152196</link>
      <description>&lt;P&gt;So any name with at least 1 non-null binary?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=summary sourcetype=prod source=service
| eventstats count(binary) as binarycount by name
| where binarycount != 0
| eval red=substr(binary, -4, 1)
| eval blue=substr(binary, -3, 1)
| fillnull value=0 red blue
| stats sum(red) AS red sum(blue) as blue by name&lt;/LI-CODE&gt;&lt;P&gt;The "where" might need to be "search"&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 09:53:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pass-field-into-a-subsearch-from-stats-command/m-p/538398#M152196</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-02-03T09:53:08Z</dc:date>
    </item>
    <item>
      <title>Re: Pass field into a subsearch from stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pass-field-into-a-subsearch-from-stats-command/m-p/538401#M152197</link>
      <description>&lt;P&gt;hmm, i seem to lose results by using this method, tried search as well as the where clause.&lt;/P&gt;&lt;P&gt;I lost two 'names' compared to when i used 'binary NOT NULL'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 10:22:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pass-field-into-a-subsearch-from-stats-command/m-p/538401#M152197</guid>
      <dc:creator>ssaenger</dc:creator>
      <dc:date>2021-02-03T10:22:56Z</dc:date>
    </item>
    <item>
      <title>Re: Pass field into a subsearch from stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pass-field-into-a-subsearch-from-stats-command/m-p/538402#M152198</link>
      <description>&lt;P&gt;What events do you have for these "lost" names and how are these different from Charles?&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 10:27:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pass-field-into-a-subsearch-from-stats-command/m-p/538402#M152198</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-02-03T10:27:15Z</dc:date>
    </item>
    <item>
      <title>Re: Pass field into a subsearch from stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pass-field-into-a-subsearch-from-stats-command/m-p/538406#M152200</link>
      <description>&lt;P&gt;I dont seem to get any results for the name charles - or entries which dont have a populated binary field - which is great.&lt;/P&gt;&lt;P&gt;However, it doesnt seem to count all the events correctly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 10:45:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pass-field-into-a-subsearch-from-stats-command/m-p/538406#M152200</guid>
      <dc:creator>ssaenger</dc:creator>
      <dc:date>2021-02-03T10:45:05Z</dc:date>
    </item>
    <item>
      <title>Re: Pass field into a subsearch from stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pass-field-into-a-subsearch-from-stats-command/m-p/538408#M152201</link>
      <description>&lt;P&gt;How are you counting the events?&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 10:49:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pass-field-into-a-subsearch-from-stats-command/m-p/538408#M152201</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-02-03T10:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: Pass field into a subsearch from stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pass-field-into-a-subsearch-from-stats-command/m-p/538413#M152203</link>
      <description>&lt;P&gt;i have edited the line you gave me to include&lt;/P&gt;&lt;PRE&gt;| stats sum(red) AS red sum(blue) as blue count(keynumber) as events by name&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 11:01:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pass-field-into-a-subsearch-from-stats-command/m-p/538413#M152203</guid>
      <dc:creator>ssaenger</dc:creator>
      <dc:date>2021-02-03T11:01:34Z</dc:date>
    </item>
    <item>
      <title>Re: Pass field into a subsearch from stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pass-field-into-a-subsearch-from-stats-command/m-p/538415#M152204</link>
      <description>&lt;LI-CODE lang="markup"&gt;| stats sum(red) AS red sum(blue) as blue count(keynumber) as events count as total by name&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 03 Feb 2021 11:03:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pass-field-into-a-subsearch-from-stats-command/m-p/538415#M152204</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-02-03T11:03:05Z</dc:date>
    </item>
    <item>
      <title>Re: Pass field into a subsearch from stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pass-field-into-a-subsearch-from-stats-command/m-p/538426#M152208</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;i am using the following to check on an individual name - this differs when i remove&lt;/P&gt;&lt;P&gt;name="Steve"&lt;/P&gt;&lt;P&gt;also differs if i add&lt;/P&gt;&lt;P&gt;binary NOT NULL&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;index=summary sourcetype=prod source=service name="Steve"&amp;nbsp;&lt;BR /&gt;| eval red=substr(binary, -4, 1)&lt;BR /&gt;| eval blue=substr(binary, -e, 1)&lt;BR /&gt;| stats sum(red) AS Red sum(blue) as Blue count(keynumber) as Events count as total by name&lt;BR /&gt;| eval Percentage_Red=(Red/Events)*100&lt;BR /&gt;| eval Percentage_Red=round(Red)&lt;BR /&gt;| eval Percentage_Blue=(Blue/Events)*100&lt;BR /&gt;| eval Percentage_Blue=round(Percentage_Blue)&lt;BR /&gt;| table name Events Red Blue Percentage_Red Percentage_Blue&lt;BR /&gt;| sort name&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;adding your entry of&amp;nbsp;&lt;/P&gt;&lt;P&gt;| search binary !=0&lt;BR /&gt;| fillnull value=0 red blue&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;makes no difference when a name field is declared&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 11:21:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pass-field-into-a-subsearch-from-stats-command/m-p/538426#M152208</guid>
      <dc:creator>ssaenger</dc:creator>
      <dc:date>2021-02-03T11:21:01Z</dc:date>
    </item>
    <item>
      <title>Re: Pass field into a subsearch from stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pass-field-into-a-subsearch-from-stats-command/m-p/538433#M152210</link>
      <description>&lt;P&gt;There are some typos here so it is not clear what you have tried&lt;/P&gt;&lt;P&gt;The answer to my previous question is that you are counting keynumber to determine how many events each name has so you don't need the count as total I suggested&lt;/P&gt;&lt;P&gt;Using where binary != 0 is different to where binarycount != 0&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=summary sourcetype=prod source=service name="Steve" 
| eventstats count(binary) as binarycount by name
| where binarycount != 0
| eval red=substr(binary, -4, 1)
| eval blue=substr(binary, -3, 1)
| fillnull value=0 red blue
| stats sum(red) AS Red sum(blue) as Blue count(keynumber) as Events by name
| eval Percentage_Red=(Red/Events)*100
| eval Percentage_Red=round(Red)
| eval Percentage_Blue=(Blue/Events)*100
| eval Percentage_Blue=round(Percentage_Blue)
| table name Events Red Blue Percentage_Red Percentage_Blue
| sort name&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 11:37:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pass-field-into-a-subsearch-from-stats-command/m-p/538433#M152210</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-02-03T11:37:01Z</dc:date>
    </item>
    <item>
      <title>Re: Pass field into a subsearch from stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pass-field-into-a-subsearch-from-stats-command/m-p/538571#M152273</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks. In the end i used a nested search to extract the name using the binary NOT NULL, then passed this through to the main search.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 08:56:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pass-field-into-a-subsearch-from-stats-command/m-p/538571#M152273</guid>
      <dc:creator>ssaenger</dc:creator>
      <dc:date>2021-02-04T08:56:46Z</dc:date>
    </item>
  </channel>
</rss>

