<?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 calculate state based on values from many searches in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-state-based-on-values-from-many-searches/m-p/488756#M136505</link>
    <description>&lt;P&gt;Hi prsepulv,&lt;BR /&gt;
let me understand, why don't you use a only one search with OR clause? in this way you haven't subsearches limit.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index=index1 sourcetype=source1) OR (index=index2 sourcetype=source2) OR (index=indexn sourcetype=sourcen) earliest=-30m latest=now()
 | rex field=_raw "State 1 (?&amp;lt;State_01&amp;gt;.),(?&amp;lt;State_02&amp;gt;.)...(?&amp;lt;State_NN&amp;gt;.)"
 | eval value1=State_01*State_02* ...    *StateNN
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then you can calculate the things you want and display the values you like, e.g. if you want some Single Values panel that display the first value (or max or sum) for each index, you can run&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index=index1 sourcetype=source1) OR (index=index2 sourcetype=source2) OR (index=indexn sourcetype=sourcen) earliest=-30m latest=now()
| rex field=_raw "State 1 (?&amp;lt;State_01&amp;gt;.),(?&amp;lt;State_02&amp;gt;.)...(?&amp;lt;State_NN&amp;gt;.)"
| eval value=State_01*State_02* ...    *StateNN
| stats first(value) AS value BY index
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;so you can display it in a panel or in multiple Single Panel using Trellis.&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
    <pubDate>Sun, 22 Sep 2019 09:24:01 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2019-09-22T09:24:01Z</dc:date>
    <item>
      <title>How to calculate state based on values from many searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-state-based-on-values-from-many-searches/m-p/488754#M136503</link>
      <description>&lt;P&gt;I'm using a dashboard to display the state of some services. For this purpose, I must takes single values from many searches to obtain a final value, like value = valu1 * value2 * value3 ... valuen&lt;BR /&gt;
The searches are like:&lt;/P&gt;

&lt;P&gt;Search1: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search index=index1 sourcetype=source1 earliest=-30m latest=now() | head 1 
| rex field=_raw "State 1 (?&amp;lt;State_01&amp;gt;.),(?&amp;lt;State_02&amp;gt;.)...(?&amp;lt;State_NN&amp;gt;.)"
| eval value1=State_01*State_02* ...    *StateNN
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Search2: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search index=index2 sourcetype=source2 earliest=-30m latest=now() | head 1 
| rex field=_raw "State 1 (?&amp;lt;State_01&amp;gt;.),(?&amp;lt;State_02&amp;gt;.)...(?&amp;lt;State_NN&amp;gt;.)"
| eval value2=State_01*State_02* ...    *StateNN
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;SearchN: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search index=indexN sourcetype=sourceN earliest=-30m latest=now() | head 1 
| rex field=_raw "State 1 (?&amp;lt;State_01&amp;gt;.),(?&amp;lt;State_02&amp;gt;.)...(?&amp;lt;State_NN&amp;gt;.)"
| eval valueN=State_01*State_02* ...    *StateNN
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and finally,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval value=value1*value2*...*valueN
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Each search works fine separately, but not together. I was using join, like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search index=index1 sourcetype=source1 earliest=-30m latest=now() | head 1 
| rex field=_raw "State 1 (?&amp;lt;State_01&amp;gt;.),(?&amp;lt;State_02&amp;gt;.)...(?&amp;lt;State_NN&amp;gt;.)"
| eval value1=State_01*State_02* ...    *StateNN
| join value2
[ search index=index2 sourcetype=source2 earliest=-30m latest=now() | head 1 
| rex field=_raw "State 1 (?&amp;lt;State_01&amp;gt;.),(?&amp;lt;State_02&amp;gt;.)...(?&amp;lt;State_NN&amp;gt;.)"
| eval value2=State_01*State_02* ...    *StateNN ]
| eval value=value1*valu2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And Splunk keeps telling me &lt;STRONG&gt;No results found&lt;/STRONG&gt;. What I'm doing wrong?&lt;/P&gt;

&lt;P&gt;Regards, &lt;/P&gt;

&lt;P&gt;Pedro&lt;/P&gt;</description>
      <pubDate>Sat, 21 Sep 2019 16:55:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-state-based-on-values-from-many-searches/m-p/488754#M136503</guid>
      <dc:creator>prsepulv</dc:creator>
      <dc:date>2019-09-21T16:55:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate state based on values from many searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-state-based-on-values-from-many-searches/m-p/488755#M136504</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;Joins are used to join 2 different search with common variable . In this scenario value* is some thing you are calculating for each search . So you should use appendcols instead of join .&lt;/P&gt;</description>
      <pubDate>Sat, 21 Sep 2019 18:53:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-state-based-on-values-from-many-searches/m-p/488755#M136504</guid>
      <dc:creator>Anantha123</dc:creator>
      <dc:date>2019-09-21T18:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate state based on values from many searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-state-based-on-values-from-many-searches/m-p/488756#M136505</link>
      <description>&lt;P&gt;Hi prsepulv,&lt;BR /&gt;
let me understand, why don't you use a only one search with OR clause? in this way you haven't subsearches limit.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index=index1 sourcetype=source1) OR (index=index2 sourcetype=source2) OR (index=indexn sourcetype=sourcen) earliest=-30m latest=now()
 | rex field=_raw "State 1 (?&amp;lt;State_01&amp;gt;.),(?&amp;lt;State_02&amp;gt;.)...(?&amp;lt;State_NN&amp;gt;.)"
 | eval value1=State_01*State_02* ...    *StateNN
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then you can calculate the things you want and display the values you like, e.g. if you want some Single Values panel that display the first value (or max or sum) for each index, you can run&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index=index1 sourcetype=source1) OR (index=index2 sourcetype=source2) OR (index=indexn sourcetype=sourcen) earliest=-30m latest=now()
| rex field=_raw "State 1 (?&amp;lt;State_01&amp;gt;.),(?&amp;lt;State_02&amp;gt;.)...(?&amp;lt;State_NN&amp;gt;.)"
| eval value=State_01*State_02* ...    *StateNN
| stats first(value) AS value BY index
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;so you can display it in a panel or in multiple Single Panel using Trellis.&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Sun, 22 Sep 2019 09:24:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-state-based-on-values-from-many-searches/m-p/488756#M136505</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-09-22T09:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate state based on values from many searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-state-based-on-values-from-many-searches/m-p/488757#M136506</link>
      <description>&lt;P&gt;I'm trying to use appendcols, &lt;STRONG&gt;the problem is that values calculated inside subsearch aren't shared to main search&lt;/STRONG&gt;. In each subsearch I find the last register and parse it with regex. And with the parsed data I calulate a single value. After that I would like to use that value on main search, with anothers values to calculate a main value.&lt;BR /&gt;
The different subsearchs are absolutely independents between them and doesn't share none data. Also lenght of registers is differente in each subsearch.&lt;/P&gt;

&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Mon, 23 Sep 2019 14:28:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-state-based-on-values-from-many-searches/m-p/488757#M136506</guid>
      <dc:creator>prsepulv</dc:creator>
      <dc:date>2019-09-23T14:28:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate state based on values from many searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-state-based-on-values-from-many-searches/m-p/488758#M136507</link>
      <description>&lt;P&gt;I tried to use it, however I calculate values from fields extracted with regex and apparently I can use only one &lt;STRONG&gt;rex field=_raw&lt;/STRONG&gt; extraction by query. If I try to use a second regex extraction, the previous data, extracted and calculated, are gone. Also the records of each search have differents lenghts and don't have any relation between them.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Sep 2019 15:42:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-state-based-on-values-from-many-searches/m-p/488758#M136507</guid>
      <dc:creator>prsepulv</dc:creator>
      <dc:date>2019-09-23T15:42:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate state based on values from many searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-state-based-on-values-from-many-searches/m-p/488759#M136508</link>
      <description>&lt;P&gt;I found an answer on this link &lt;A href="https://answers.splunk.com/answers/240798/how-to-return-a-single-value-from-a-subsearch-into.html"&gt;https://answers.splunk.com/answers/240798/how-to-return-a-single-value-from-a-subsearch-into.html&lt;/A&gt;&lt;BR /&gt;
It works, like a charm...&lt;/P&gt;

&lt;P&gt;Thank you very much to all.&lt;/P&gt;

&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Mon, 23 Sep 2019 21:44:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-state-based-on-values-from-many-searches/m-p/488759#M136508</guid>
      <dc:creator>prsepulv</dc:creator>
      <dc:date>2019-09-23T21:44:45Z</dc:date>
    </item>
  </channel>
</rss>

