<?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: SPL subquery for table in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/SPL-subquery-for-table/m-p/549255#M155837</link>
    <description>&lt;P&gt;Thank you, Tscroggins.&lt;/P&gt;&lt;P&gt;Streamstats is new for me. I tried executing query till streamstats (without where)&amp;nbsp; but value of "u" is blanks in output. I will learn more about streamstats to know where am I going wrong.&lt;/P&gt;&lt;P&gt;Thank you so kuch for giving direction to solution.&lt;/P&gt;</description>
    <pubDate>Sun, 25 Apr 2021 07:01:10 GMT</pubDate>
    <dc:creator>Anandkalhore</dc:creator>
    <dc:date>2021-04-25T07:01:10Z</dc:date>
    <item>
      <title>SPL subquery for table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SPL-subquery-for-table/m-p/549223#M155824</link>
      <description>&lt;P class="lia-indent-padding-left-30px"&gt;Hi,&lt;/P&gt;&lt;P&gt;Need help.&lt;/P&gt;&lt;P&gt;I want to run a query to identify if errors are increased over 10%.&lt;/P&gt;&lt;P&gt;Data is :&lt;/P&gt;&lt;P&gt;Servername errorcode1 errorcode2 count&lt;/P&gt;&lt;P&gt;Abcd.1.1.1000&lt;/P&gt;&lt;P&gt;Pqrs.1.2.1100&lt;/P&gt;&lt;P&gt;If errorcode2 value 1 txns are exceeding 10% of average count of its historical(7 days) count then show alert. I need to do this for all types of available errors in a single query.&lt;/P&gt;&lt;P&gt;I could do it for a single error code.. but i want query for all error code at once.&lt;/P&gt;&lt;P&gt;Index=abcd errorcode2 in (1) earliest=-1d@d latest=@d&lt;/P&gt;&lt;P&gt;|Stats coubt as t1 by errorcode2&lt;/P&gt;&lt;P&gt;|Table t1 | where t1 &amp;gt; 【 search index=abcd&amp;nbsp;errorcode2 in (1) earliest=-8d@d latest=-2d@d&lt;/P&gt;&lt;P&gt;Bucket _time span=1d&lt;/P&gt;&lt;P&gt;|Stats count as total by _time&lt;/P&gt;&lt;P&gt;|Stats avg(total)as avgt&lt;/P&gt;&lt;P&gt;|Eval chk = 1.1* avgt&lt;/P&gt;&lt;P&gt;|Table chk | return $chk】&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kindky help me understand how can I compare complete table in where condition like we do in python pandas.&lt;/P&gt;</description>
      <pubDate>Sat, 24 Apr 2021 18:47:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SPL-subquery-for-table/m-p/549223#M155824</guid>
      <dc:creator>Anandkalhore</dc:creator>
      <dc:date>2021-04-24T18:47:24Z</dc:date>
    </item>
    <item>
      <title>Re: SPL subquery for table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SPL-subquery-for-table/m-p/549229#M155827</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/233776"&gt;@Anandkalhore&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Assuming one raw event per day per combination of Servername, errorcode1, and errorcode2:&lt;/P&gt;&lt;P&gt;Abcd.1.1.1000&lt;BR /&gt;Pqrs.1.2.1100&lt;/P&gt;&lt;P&gt;and field extractions:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="25%"&gt;&lt;STRONG&gt;Servername&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="25%"&gt;&lt;STRONG&gt;errorcode1&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="25%"&gt;&lt;STRONG&gt;errorcode2&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="25%"&gt;&lt;STRONG&gt;count&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%"&gt;Abcd&lt;/TD&gt;&lt;TD width="25%"&gt;1&lt;/TD&gt;&lt;TD width="25%"&gt;1&lt;/TD&gt;&lt;TD width="25%"&gt;1000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%"&gt;Pqrs&lt;/TD&gt;&lt;TD width="25%"&gt;1&lt;/TD&gt;&lt;TD width="25%"&gt;2&lt;/TD&gt;&lt;TD width="25%"&gt;1100&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;we can create labels for each value of errorcode1 and errorcode2:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;index=foo sourcetype=bar earliest=-8d@d latest=@d
| foreach errorcode* [ eval errorcode=mvappend(errorcode, "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"."-".&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;) ]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1" width="125%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="25%" height="25px"&gt;&lt;STRONG&gt;Servername&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;&lt;STRONG&gt;errorcode&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="25%"&gt;&lt;STRONG&gt;errorcode1&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="25%"&gt;&lt;STRONG&gt;errorcode2&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="25%"&gt;&lt;STRONG&gt;count&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%"&gt;Abcd&lt;/TD&gt;&lt;TD width="25%"&gt;&lt;P&gt;errorcode1-1&lt;BR /&gt;errorcode2-1&lt;/P&gt;&lt;/TD&gt;&lt;TD width="25%"&gt;1&lt;/TD&gt;&lt;TD width="25%"&gt;1&lt;/TD&gt;&lt;TD width="25%"&gt;1000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%"&gt;Pqrs&lt;/TD&gt;&lt;TD width="25%"&gt;errorcode1-1&lt;BR /&gt;errorcode2-2&lt;/TD&gt;&lt;TD width="25%"&gt;1&lt;/TD&gt;&lt;TD width="25%"&gt;2&lt;/TD&gt;&lt;TD width="25%"&gt;1100&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and split them into distinct events:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;index=foo sourcetype=bar earliest=-8d@d latest=@d
| foreach errorcode* [ eval errorcode=mvappend(errorcode, "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"."-".&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;) ]
| mvexpand errorcode&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1" width="990px"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="198px" height="25px"&gt;&lt;STRONG&gt;Servername&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="198px" height="25px"&gt;&lt;STRONG&gt;errorcode&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="198px"&gt;&lt;STRONG&gt;errorcode1&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="198px"&gt;&lt;STRONG&gt;errorcode2&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="198px"&gt;&lt;STRONG&gt;count&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="198px"&gt;Abcd&lt;/TD&gt;&lt;TD width="198px"&gt;&lt;P&gt;errorcode1-1&lt;/P&gt;&lt;/TD&gt;&lt;TD width="198px"&gt;1&lt;/TD&gt;&lt;TD width="198px"&gt;1&lt;/TD&gt;&lt;TD width="198px"&gt;1000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="198px"&gt;Abcd&lt;/TD&gt;&lt;TD width="198px"&gt;&lt;P&gt;errorcode2-1&lt;/P&gt;&lt;/TD&gt;&lt;TD width="198px"&gt;1&lt;/TD&gt;&lt;TD width="198px"&gt;1&lt;/TD&gt;&lt;TD width="198px"&gt;1000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="198px"&gt;Pqrs&lt;/TD&gt;&lt;TD width="198px"&gt;errorcode1-1&lt;/TD&gt;&lt;TD width="198px"&gt;1&lt;/TD&gt;&lt;TD width="198px"&gt;2&lt;/TD&gt;&lt;TD width="198px"&gt;1100&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="198px"&gt;Pqrs&lt;/TD&gt;&lt;TD width="198px"&gt;errorcode2-2&lt;/TD&gt;&lt;TD width="198px"&gt;1&lt;/TD&gt;&lt;TD width="198px"&gt;2&lt;/TD&gt;&lt;TD width="198px"&gt;1100&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Finally, we can calculate the average by errorcode and return only events from yesterday with counts greater than 10% of the average of the prior 7 days:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;index=foo sourcetype=bar earliest=-8d@d latest=@d
| foreach errorcode* [ eval errorcode=mvappend(errorcode, "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"."-".&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;) ]
| mvexpand errorcode
| streamstats current=f global=f window=7 avg(count) as u by errorcode
| where where _time&amp;gt;=relative_time(now(), "-1d@d") AND _time&amp;lt;relative_time(now(), "@d") AND count&amp;gt;(u*0.1)
| table _time Servername errorcode1 errorcode2 count
| dedup Servername errorcode1 errorcode2&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 24 Apr 2021 23:49:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SPL-subquery-for-table/m-p/549229#M155827</guid>
      <dc:creator>tscroggins</dc:creator>
      <dc:date>2021-04-24T23:49:41Z</dc:date>
    </item>
    <item>
      <title>Re: SPL subquery for table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SPL-subquery-for-table/m-p/549255#M155837</link>
      <description>&lt;P&gt;Thank you, Tscroggins.&lt;/P&gt;&lt;P&gt;Streamstats is new for me. I tried executing query till streamstats (without where)&amp;nbsp; but value of "u" is blanks in output. I will learn more about streamstats to know where am I going wrong.&lt;/P&gt;&lt;P&gt;Thank you so kuch for giving direction to solution.&lt;/P&gt;</description>
      <pubDate>Sun, 25 Apr 2021 07:01:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SPL-subquery-for-table/m-p/549255#M155837</guid>
      <dc:creator>Anandkalhore</dc:creator>
      <dc:date>2021-04-25T07:01:10Z</dc:date>
    </item>
  </channel>
</rss>

