<?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: stats count when a given when A &amp;gt; some value AND B &amp;gt; some value in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/stats-count-when-a-given-when-A-gt-some-value-AND-B-gt-some/m-p/668418#M229309</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/257114"&gt;@man03359&lt;/a&gt;&amp;nbsp;.. the metricName can be either&amp;nbsp;&lt;SPAN&gt;CPUPercentage or MemoryPercentage.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;and then, how do you get the value of either&amp;nbsp;CPUPercentage or MemoryPercentage&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;or.. if you have the values for&amp;nbsp;either&amp;nbsp;CPUPercentage or MemoryPercentage.. then you should be able to run:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;index=idx-cloud-azure "*09406b3b-b643-4e86-876e-4cd5f5a8be57*"
| chart count by index, metricName
| where CpuPercentage &amp;gt; 85 AND MemoryPercentage &amp;gt; 85&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;when you run this Search query, do you get results as you expected ah.. if yes, then you can save it as an alert.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let us know if this about search works fine.. if its not working, pls update us how to get the values of either cpu or memory percentage. thanks.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 13 Nov 2023 11:57:20 GMT</pubDate>
    <dc:creator>inventsekar</dc:creator>
    <dc:date>2023-11-13T11:57:20Z</dc:date>
    <item>
      <title>stats count when a given when A &gt; some value AND B &gt; some value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-when-a-given-when-A-gt-some-value-AND-B-gt-some/m-p/667480#M228976</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;Hope everyone is alright.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the below base search. I am trying to built an alert&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=idx-cloud-azure "*09406b3b-b643-4e86-876e-4cd5f5a8be57*" metricName=MemoryPercentage OR metricName=CpuPercentage&lt;/LI-CODE&gt;&lt;P&gt;This is the below condition which I have to follow-&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;CPUPercentage &amp;gt; 85&amp;nbsp;MemoryPercentage &amp;gt; 85, where CPUPercentage and MemoryPercentage are values of a field called metricName.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I am doing like this -&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=idx-cloud-azure "*09406b3b-b643-4e86-876e-4cd5f5a8be57*"
| eval metricCount=if((metricName="MemoryPercentage" OR metricName="CpuPercentage"),1,0)
| stats count by metricCount
| where MemoryPercentage &amp;gt; 85 OR CpuPercentage &amp;gt; 85&lt;/LI-CODE&gt;&lt;P&gt;not sure if this is correct way to do.&lt;/P&gt;&lt;P&gt;Could anyone pls suggest a better way.&lt;/P&gt;&lt;P&gt;Thanks in advance &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 10:36:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-when-a-given-when-A-gt-some-value-AND-B-gt-some/m-p/667480#M228976</guid>
      <dc:creator>man03359</dc:creator>
      <dc:date>2023-11-06T10:36:13Z</dc:date>
    </item>
    <item>
      <title>Re: stats count when a given when A &gt; some value AND B &gt; some value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-when-a-given-when-A-gt-some-value-AND-B-gt-some/m-p/667483#M228977</link>
      <description>&lt;P&gt;Without knowing what your events look like, it is difficult to say whether this is right or not. For example, do CPUPercentage and MemoryPercentage appear in the same event?&lt;/P&gt;&lt;P&gt;Having said that "stats count by metricCount" is almost certainly wrong as all you will be left with a single field called count so the where command will always be false.&lt;/P&gt;&lt;P&gt;Also, you title suggests an AND condition but your where command is using an OR condition. This is a bit confusing.&lt;/P&gt;&lt;P&gt;Please clarify what you are trying to do and include some (anonymised) representative sample event, preferably unformatted in a code block &amp;lt;/&amp;gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 10:56:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-when-a-given-when-A-gt-some-value-AND-B-gt-some/m-p/667483#M228977</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-11-06T10:56:04Z</dc:date>
    </item>
    <item>
      <title>Re: stats count when a given when A &gt; some value AND B &gt; some value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-when-a-given-when-A-gt-some-value-AND-B-gt-some/m-p/667499#M228982</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The logs look like this -&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; amdl_ResourceGroup: PLANALLOC-GSAS-NONPROD-IACD01-EUS2-GSAS-RG
   amdl_ResourceName: ALLOC-EUS2-IACD01-GSAS-WINASP01
   amdl_ResourceType: MICROSOFT.WEB/SERVERFARMS
   amdl_SubscriptionId: 09406B3B-B643-4E86-876E-4CD5F5A8BE57
   average: 0
   count: 1
   maximum: 0
   metricName: CpuPercentage
   minimum: 0
   resourceId: /SUBSCRIPTIONS/09406B3B-B643-4E86-876E-4CD5F5A8BE57/RESOURCEGROUPS/PLANALLOC-GSAS-NONPROD-IACD01-EUS2-GSAS-RG/PROVIDERS/MICROSOFT.WEB/SERVERFARMS/ALLOC-EUS2-IACD01-GSAS-WINASP01
   time: 2023-11-06T11:38:00Z
   timeGrain: PT1M
   total: 0&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 06 Nov 2023 11:44:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-when-a-given-when-A-gt-some-value-AND-B-gt-some/m-p/667499#M228982</guid>
      <dc:creator>man03359</dc:creator>
      <dc:date>2023-11-06T11:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: stats count when a given when A &gt; some value AND B &gt; some value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-when-a-given-when-A-gt-some-value-AND-B-gt-some/m-p/667501#M228983</link>
      <description>&lt;P&gt;So, each event has a metricName?&lt;/P&gt;&lt;P&gt;Which value are you comparing to 85, or are you just looking to count the different metricNames and see if you have more than 85 of both?&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 11:48:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-when-a-given-when-A-gt-some-value-AND-B-gt-some/m-p/667501#M228983</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-11-06T11:48:33Z</dc:date>
    </item>
    <item>
      <title>Re: stats count when a given when A &gt; some value AND B &gt; some value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-when-a-given-when-A-gt-some-value-AND-B-gt-some/m-p/667502#M228984</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CPUPercentage and MemoryPercentage are the field values of a field called metricName.&lt;/P&gt;&lt;P&gt;The condition for the alert is -&lt;/P&gt;&lt;P&gt;when the count of CPUPercentage &amp;gt; 85 and MemoryPercentage &amp;gt; 85, it should trigger an alert.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please refer to the screenshot attached.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 11:49:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-when-a-given-when-A-gt-some-value-AND-B-gt-some/m-p/667502#M228984</guid>
      <dc:creator>man03359</dc:creator>
      <dc:date>2023-11-06T11:49:06Z</dc:date>
    </item>
    <item>
      <title>Re: stats count when a given when A &gt; some value AND B &gt; some value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-when-a-given-when-A-gt-some-value-AND-B-gt-some/m-p/667503#M228985</link>
      <description>&lt;P&gt;This will give you what you have asked for, although I am not sure of the value of it as if your timeframe is wide enough, you will eventually get more than 85 events of each metric.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=idx-cloud-azure "*09406b3b-b643-4e86-876e-4cd5f5a8be57*"
| chart count by index, metricName
| where CpuPercentage &amp;gt; 85 AND MemoryPercentage &amp;gt; 85&lt;/LI-CODE&gt;&lt;P&gt;,&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 11:55:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-when-a-given-when-A-gt-some-value-AND-B-gt-some/m-p/667503#M228985</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-11-06T11:55:57Z</dc:date>
    </item>
    <item>
      <title>Re: stats count when a given when A &gt; some value AND B &gt; some value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-when-a-given-when-A-gt-some-value-AND-B-gt-some/m-p/667506#M228986</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The base search is -&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=idx-cloud-azure "*09406b3b-b643-4e86-876e-4cd5f5a8be57*"&lt;/LI-CODE&gt;&lt;P&gt;and the logs with this search looks like-&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;amal_ResourceGroup: PLANALLOC-GSAS-NONPROD-D01-EUS2-GSAS-RG
   amal_ResourceName: ALLOCD01GSASTENANTCOSMOSDBACCOUNT01 - COSMOSDB ACCOUNT ADMIN OPERATION
   amal_ResourceType: MICROSOFT.INSIGHTS/ACTIVITYLOGALERTS
   amal_SubscriptionId: 09406B3B-B643-4E86-876E-4CD5F5A8BE57
   caller: Microsoft.Insights/ActivityLogAlerts
   category: Alert
   correlationId: 6132ca53-ed10-4f13-8c2a-5496dd7decde
   identity: { [+]
   }
   level: Informational
   location: global
   operationName: Microsoft.Insights/ActivityLogAlerts/Activated/action
   properties: { [+]
   }
   resourceId: /subscriptions/09406b3b-b643-4e86-876e-4cd5f5a8be57/resourceGroups/planalloc-gsas-nonprod-d01-eus2-gsas-rg/providers/microsoft.insights/activityLogAlerts/allocd01gsastenantcosmosdbaccount01 - CosmosDB Account Admin Operation
   resultDescription: Alert: allocd01gsastenantcosmosdbaccount01 - CosmosDB Account Admin Operation called on action groups : alloceus2d01ag01
   resultType: Succeeded
   time: 2023-11-06T11:53:58.8277854Z&lt;/LI-CODE&gt;&lt;P&gt;I have a field called "metricName" one of those values are CpuPercentage , MemoryPercentage etc. listed in the image&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="man03359_0-1699271968838.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/27956i4868B4293E6D3711/image-size/medium?v=v2&amp;amp;px=400" role="button" title="man03359_0-1699271968838.png" alt="man03359_0-1699271968838.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So I am filtering my search with the metricName like this -&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=idx-cloud-azure "*09406b3b-b643-4e86-876e-4cd5f5a8be57*" metricName="MemoryPercentage" OR metricName="CpuPercentage"&lt;/LI-CODE&gt;&lt;P&gt;The condition for the alert is -&lt;/P&gt;&lt;P&gt;when the count of CPUPercentage &amp;gt; 85 and MemoryPercentage &amp;gt; 85, it should trigger and alert.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 12:03:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-when-a-given-when-A-gt-some-value-AND-B-gt-some/m-p/667506#M228986</guid>
      <dc:creator>man03359</dc:creator>
      <dc:date>2023-11-06T12:03:57Z</dc:date>
    </item>
    <item>
      <title>Re: stats count when a given when A &gt; some value AND B &gt; some value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-when-a-given-when-A-gt-some-value-AND-B-gt-some/m-p/667508#M228987</link>
      <description>&lt;P&gt;OK, so use the search I gave you for your alert and trigger when there are results.&lt;/P&gt;&lt;P&gt;But, again, I am not sure how useful this is. What are you actually trying to achieve?&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 12:21:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-when-a-given-when-A-gt-some-value-AND-B-gt-some/m-p/667508#M228987</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-11-06T12:21:42Z</dc:date>
    </item>
    <item>
      <title>Re: stats count when a given when A &gt; some value AND B &gt; some value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-when-a-given-when-A-gt-some-value-AND-B-gt-some/m-p/668413#M229306</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, each event has metricName, listed like this-&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="man03359_0-1699872352470.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28082i3B21E8D75815109D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="man03359_0-1699872352470.png" alt="man03359_0-1699872352470.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;CpuPercentage and MemoryPercentage are one of the values of metricName.&lt;/P&gt;&lt;P&gt;The query has to be built in such a way that it calculates the % of CPU utilization and throws an alert when the CPUPercentage is more than 85%., similarly for MemoryPercentage also.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2023 10:48:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-when-a-given-when-A-gt-some-value-AND-B-gt-some/m-p/668413#M229306</guid>
      <dc:creator>man03359</dc:creator>
      <dc:date>2023-11-13T10:48:40Z</dc:date>
    </item>
    <item>
      <title>Re: stats count when a given when A &gt; some value AND B &gt; some value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-when-a-given-when-A-gt-some-value-AND-B-gt-some/m-p/668414#M229307</link>
      <description>&lt;P&gt;This doesn't really answer the question.&lt;/P&gt;&lt;P&gt;How about this (to try and clarify what your events mean): Is the count always 1?&lt;/P&gt;&lt;P&gt;If so, it appears that average, minimum, maximum and total will always be the same number, right? That is, any one of them could be used as the value for the event?&lt;/P&gt;&lt;P&gt;If not, which value do you want to use as the value for the event?&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2023 11:03:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-when-a-given-when-A-gt-some-value-AND-B-gt-some/m-p/668414#M229307</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-11-13T11:03:02Z</dc:date>
    </item>
    <item>
      <title>Re: stats count when a given when A &gt; some value AND B &gt; some value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-when-a-given-when-A-gt-some-value-AND-B-gt-some/m-p/668418#M229309</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/257114"&gt;@man03359&lt;/a&gt;&amp;nbsp;.. the metricName can be either&amp;nbsp;&lt;SPAN&gt;CPUPercentage or MemoryPercentage.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;and then, how do you get the value of either&amp;nbsp;CPUPercentage or MemoryPercentage&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;or.. if you have the values for&amp;nbsp;either&amp;nbsp;CPUPercentage or MemoryPercentage.. then you should be able to run:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;index=idx-cloud-azure "*09406b3b-b643-4e86-876e-4cd5f5a8be57*"
| chart count by index, metricName
| where CpuPercentage &amp;gt; 85 AND MemoryPercentage &amp;gt; 85&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;when you run this Search query, do you get results as you expected ah.. if yes, then you can save it as an alert.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let us know if this about search works fine.. if its not working, pls update us how to get the values of either cpu or memory percentage. thanks.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2023 11:57:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-when-a-given-when-A-gt-some-value-AND-B-gt-some/m-p/668418#M229309</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2023-11-13T11:57:20Z</dc:date>
    </item>
  </channel>
</rss>

