<?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: Calculate a value based on multiple events in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Calculate-a-value-based-on-multiple-events/m-p/143760#M39961</link>
    <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;key=mycounter OR key=mytime | eval value_{key} = value | stats first(value_*) as * by id | eval result = mycounter / mytime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The first &lt;CODE&gt;eval&lt;/CODE&gt; creates two fields, &lt;CODE&gt;value_mycounter&lt;/CODE&gt; and &lt;CODE&gt;value_mytime&lt;/CODE&gt;. The &lt;CODE&gt;stats&lt;/CODE&gt; merges the two events into one for each &lt;CODE&gt;id&lt;/CODE&gt;. The final &lt;CODE&gt;eval&lt;/CODE&gt; does the actual maths.&lt;/P&gt;</description>
    <pubDate>Sun, 28 Sep 2014 20:23:41 GMT</pubDate>
    <dc:creator>martin_mueller</dc:creator>
    <dc:date>2014-09-28T20:23:41Z</dc:date>
    <item>
      <title>Calculate a value based on multiple events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-a-value-based-on-multiple-events/m-p/143759#M39960</link>
      <description>&lt;P&gt;My events have the following structure:&lt;BR /&gt;
&lt;CODE&gt;id=[id] key=[key] value=[value]&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;For example:&lt;BR /&gt;
&lt;CODE&gt;id=1 key=mycounter value=4&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;id=1 key=mytime value=40&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;id=2 key=mycounter value=5&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;id=2 key=mytime value=70&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;id=3 key=mycounter value=8&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;id=3 key=mytime value=90&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;I would like to calculate &lt;CODE&gt;mycounter/mytime&lt;/CODE&gt; for each &lt;CODE&gt;id&lt;/CODE&gt;.&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;I created a table (&lt;CODE&gt;(key=mycounter OR key=mytime) | dedup id, key | table id, key, value&lt;/CODE&gt;) and tried to apply &lt;CODE&gt;mvcombine&lt;/CODE&gt; and &lt;CODE&gt;makemv&lt;/CODE&gt;, but I was not able to get it working. Is this the right way to go or is there a better way in Splunk?&lt;/P&gt;</description>
      <pubDate>Sun, 28 Sep 2014 20:20:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-a-value-based-on-multiple-events/m-p/143759#M39960</guid>
      <dc:creator>larsxschneider</dc:creator>
      <dc:date>2014-09-28T20:20:48Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate a value based on multiple events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-a-value-based-on-multiple-events/m-p/143760#M39961</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;key=mycounter OR key=mytime | eval value_{key} = value | stats first(value_*) as * by id | eval result = mycounter / mytime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The first &lt;CODE&gt;eval&lt;/CODE&gt; creates two fields, &lt;CODE&gt;value_mycounter&lt;/CODE&gt; and &lt;CODE&gt;value_mytime&lt;/CODE&gt;. The &lt;CODE&gt;stats&lt;/CODE&gt; merges the two events into one for each &lt;CODE&gt;id&lt;/CODE&gt;. The final &lt;CODE&gt;eval&lt;/CODE&gt; does the actual maths.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Sep 2014 20:23:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-a-value-based-on-multiple-events/m-p/143760#M39961</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-09-28T20:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate a value based on multiple events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-a-value-based-on-multiple-events/m-p/143761#M39962</link>
      <description>&lt;P&gt;Awesome! Thank you very much!&lt;/P&gt;</description>
      <pubDate>Sun, 28 Sep 2014 20:28:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-a-value-based-on-multiple-events/m-p/143761#M39962</guid>
      <dc:creator>larsxschneider</dc:creator>
      <dc:date>2014-09-28T20:28:43Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate a value based on multiple events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-a-value-based-on-multiple-events/m-p/143762#M39963</link>
      <description>&lt;P&gt;Gerne! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Sep 2014 20:30:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-a-value-based-on-multiple-events/m-p/143762#M39963</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-09-28T20:30:26Z</dc:date>
    </item>
  </channel>
</rss>

