<?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: Comparing fields from two events in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Comparing-fields-from-two-events/m-p/128402#M34852</link>
    <description>&lt;P&gt;do you have &lt;CODE&gt;req_time, pmi_nodename and pmi_servername&lt;/CODE&gt; fields in all events?&lt;/P&gt;</description>
    <pubDate>Fri, 11 Apr 2014 08:36:04 GMT</pubDate>
    <dc:creator>MuS</dc:creator>
    <dc:date>2014-04-11T08:36:04Z</dc:date>
    <item>
      <title>Comparing fields from two events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-fields-from-two-events/m-p/128401#M34851</link>
      <description>&lt;P&gt;The data shown here is PMI (Performance Monitoring Infrastructure) data collected from WebSphere using a scripting framework from IBM. I am therefore not really able to format the output in any other way than shown below. Problem is that in order to create an alert for exhausted ThreadPools I need to compare fields from two events, as shown below&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2014-04-11 08:32:33:902,node02,CEMember2,type=ThreadPool+name=WebContainer&amp;gt;WebContainer,WebContainer,threadPoolModule,PoolSize,id,4,type,BoundedRangeStatistic,lastSampleTime,2014-04-11 05:27:24:069,current,13,bounded,50...50,waterMarks,1...50,mean,9.227478332840127,integral,3.34956227E8
2014-04-11 08:32:33:902,node02,CEMember2,type=ThreadPool+name=WebContainer&amp;gt;WebContainer,WebContainer,threadPoolModule,ActiveCount,id,3,type,BoundedRangeStatistic,lastSampleTime,2014-04-11 08:32:29:404,current,2,bounded,0...0,waterMarks,1...11,mean,2.6708347887819315,integral,1.2661146E8
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have created a custom sourcetype creating fields, the one needed (as I am aware of) for this question is&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;req_time = 2014-04-11 08:32:33:902&lt;/LI&gt;
&lt;LI&gt;pmi_node_name = node02&lt;/LI&gt;
&lt;LI&gt;pmi_server_name = CEMember2&lt;/LI&gt;
&lt;LI&gt;pmi_stat_provider_short = WebContainer&lt;/LI&gt;
&lt;LI&gt;pmi_statistics_name = {PoolSize|ActiveCount}&lt;/LI&gt;
&lt;LI&gt;pmi_current = {13|2}&lt;/LI&gt;
&lt;LI&gt;pmi_bounded = {0|50}&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;I have created an alert like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=pmi_threadpool_events pmi_bounded &amp;gt; 0 | where pmi_current&amp;gt;pmi_bounded
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But I have realized that I want this (pseudocode)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=pmi_threadpool_events | where the following fields match: (req_time AND pmi_nodename AND pmi_servername AND pmi_stat_provider_short  AND THEN ((pmi_statistics_name = ActiveCount) pmi_current) &amp;gt; ((pmi_statistics_name = PoolSize)pmi_bounded) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That is - since I check several nodes and servers at the same time returning several pmi_stat_provider_short I need to have identical req_time, pmi_nodename, pmi_servername and pmi_stat_provider_short to know that the events is a &lt;EM&gt;transaction&lt;/EM&gt;, and then check if pmi_current from the event with pmi_statistics_name = ActiveCount is greater than or equal to pmi_bounded from the event with pmi_statistics_name = PoolSize. &lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:22:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-fields-from-two-events/m-p/128401#M34851</guid>
      <dc:creator>rune_hellem</dc:creator>
      <dc:date>2020-09-28T16:22:03Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing fields from two events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-fields-from-two-events/m-p/128402#M34852</link>
      <description>&lt;P&gt;do you have &lt;CODE&gt;req_time, pmi_nodename and pmi_servername&lt;/CODE&gt; fields in all events?&lt;/P&gt;</description>
      <pubDate>Fri, 11 Apr 2014 08:36:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-fields-from-two-events/m-p/128402#M34852</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-04-11T08:36:04Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing fields from two events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-fields-from-two-events/m-p/128403#M34853</link>
      <description>&lt;P&gt;Yes, all events have all fields as shown above, that is safe to assume&lt;/P&gt;</description>
      <pubDate>Fri, 11 Apr 2014 08:38:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-fields-from-two-events/m-p/128403#M34853</guid>
      <dc:creator>rune_hellem</dc:creator>
      <dc:date>2014-04-11T08:38:58Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing fields from two events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-fields-from-two-events/m-p/128404#M34854</link>
      <description>&lt;P&gt;How about this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=pmi_threadpool_events pmi_statistics_name = ActiveCount OR pmi_statistics_name = PoolSize | stats max(pmi_current) as pmi_current max(pmi_bounded) as pmi_bounded by req_time, pmi_nodename, pmi_servername | where pmi_current&amp;gt;pmi_bounded
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;Updated answer.&lt;BR /&gt;
Try this. I have eliminated the &lt;CODE&gt;pmi_current&lt;/CODE&gt; field from events with &lt;CODE&gt;pmi_statistics=ActiveCount&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|multisearch [search sourcetype=pmi_threadpool_events pmi_statistics_name = ActiveCount | table req_time, pmi_nodename, pmi_servername, pmi_statistics_name, pmi_current,pmi_stat_provider_long][search  sourcetype=pmi_threadpool_events pmi_statistics_name = PoolSize | table req_time, pmi_nodename, pmi_servername, pmi_statistics_name,pmi_bounded,pmi_stat_provider_long] | stats max(pmi_current) as pmi_current max(pmi_bounded) as pmi_bounded by req_time, pmi_nodename, pmi_servername | where pmi_current&amp;gt;pmi_bounded
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Apr 2014 12:58:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-fields-from-two-events/m-p/128404#M34854</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-04-11T12:58:38Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing fields from two events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-fields-from-two-events/m-p/128405#M34855</link>
      <description>&lt;P&gt;To reflect my latest edit, I updated the search string to have pmi_stat_provider_short in the by clause&lt;/P&gt;

&lt;P&gt;sourcetype=pmi_threadpool_events pmi_statistics_name = ActiveCount OR pmi_statistics_name = PoolSize | stats max(pmi_current) as pmi_current max(pmi_bounded) as pmi_bounded by req_time, pmi_node_name, pmi_server_name,pmi_stat_provider_long | where pmi_current&amp;gt;pmi_bounded&lt;/P&gt;

&lt;P&gt;It is close, but still no sigar - since both events have the field pmi_current it will select random from either one of the events, which is not correct since PoolSize pmi_current can be higher than ActiveCount&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:22:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-fields-from-two-events/m-p/128405#M34855</guid>
      <dc:creator>rune_hellem</dc:creator>
      <dc:date>2020-09-28T16:22:39Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing fields from two events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-fields-from-two-events/m-p/128406#M34856</link>
      <description>&lt;P&gt;Try the updated answer. I have included your new field pmi_stat_provider_short in it.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:22:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-fields-from-two-events/m-p/128406#M34856</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2020-09-28T16:22:55Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing fields from two events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-fields-from-two-events/m-p/128407#M34857</link>
      <description>&lt;P&gt;Hi Rune,&lt;/P&gt;

&lt;P&gt;Could you throw in an eval with if to NULL out the pmi_current you don't need, combined with the answer from somesoni2? As far as I understand you're only interested in the pmi_current from one of the events, i.e. &lt;/P&gt;

&lt;P&gt;| eval pmi_current=if(pmi_statistics_name == "ActiveCount", pmi_current, NULL)&lt;/P&gt;

&lt;P&gt;?&lt;/P&gt;

&lt;P&gt;Not sure if that's what you're looking for, just an idea &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;You could also check this out: &lt;A href="http://answers.splunk.com/answers/93930/how-to-create-a-new-field-with-values-in-existing-field-based-on-the-values-in-other-field" target="_blank"&gt;http://answers.splunk.com/answers/93930/how-to-create-a-new-field-with-values-in-existing-field-based-on-the-values-in-other-field&lt;/A&gt;&lt;BR /&gt;
You might lose some important data with this approach though. I guess your BY clause would be pmi_statistics_name&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:25:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-fields-from-two-events/m-p/128407#M34857</guid>
      <dc:creator>mikaelbje</dc:creator>
      <dc:date>2020-09-28T16:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing fields from two events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-fields-from-two-events/m-p/128408#M34858</link>
      <description>&lt;P&gt;Solved - thanks Mikael for the eval-command&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=pmi_threadpool_events  | eval pmi_current=if(pmi_statistics_name == "ActiveCount", pmi_current, NULL)  | eval pmi_bounded=if(pmi_statistics_name == "PoolSize", pmi_bounded, NULL) | transaction _time,pmi_node_name,pmi_server_name,pmi_stat_provider_long | WHERE pmi_current &amp;gt;= pmi_bounded
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Apr 2014 11:49:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-fields-from-two-events/m-p/128408#M34858</guid>
      <dc:creator>rune_hellem</dc:creator>
      <dc:date>2014-04-24T11:49:57Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing fields from two events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-fields-from-two-events/m-p/128409#M34859</link>
      <description>&lt;P&gt;Got the error &lt;/P&gt;

&lt;P&gt;"...Multisearch subsearches may only contain purely streaming operations..."&lt;/P&gt;

&lt;P&gt;and after trying out the eval command provided by Mikael I remembered the transaction-command.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Apr 2014 11:53:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-fields-from-two-events/m-p/128409#M34859</guid>
      <dc:creator>rune_hellem</dc:creator>
      <dc:date>2014-04-24T11:53:41Z</dc:date>
    </item>
  </channel>
</rss>

