{"id":61370,"date":"2022-08-03T19:03:01","date_gmt":"2022-08-03T19:03:01","guid":{"rendered":"https:\/\/merikebi.warrenmyers.com\/?p=61370"},"modified":"2022-08-03T19:03:01","modified_gmt":"2022-08-03T19:03:01","slug":"answer-by-warren-for-how-to-combine-count-from-two-different-mstats-in-where-clause-splunk","status":"publish","type":"post","link":"https:\/\/merikebi.warrenmyers.com\/?p=61370","title":{"rendered":"Answer by warren for How to combine count from two different mstats in where clause Splunk?"},"content":{"rendered":"<p>Per the docs.Splunk entry for <a href=\"https:\/\/docs.splunk.com\/Documentation\/Splunk\/latest\/SearchReference\/mstats#Usage\" rel=\"nofollow noreferrer\"><code>mstats<\/code><\/a>, you can <a href=\"https:\/\/docs.splunk.com\/Documentation\/Splunk\/latest\/SearchReference\/append\" rel=\"nofollow noreferrer\"><code>append<\/code><\/a> another <code>mstats<\/code> call. So something like this should work:<\/p>\n<pre><code>| mstats count(_value) as count2 WHERE metric_name=&quot;*metric2*&quot; AND metric_type=c AND status=&quot;success&quot; by metric_name,env,status\n| where count2=0\n| append\n    [| mstats count(_value) as count1 WHERE metric_name=&quot;*metric1*&quot; AND metric_type=c AND status=&quot;success&quot; by metric_name,env,status\n    | where count1&gt;0 ]\n<\/code><\/pre>\n<p>You should then be able to post-process the <code>append<\/code>ed search results as desired<\/p>\n<p>from User warren &#8211; Stack Overflow https:\/\/stackoverflow.com\/questions\/73223933\/how-to-combine-count-from-two-different-mstats-in-where-clause-splunk\/73226482#73226482<br \/>\nvia <a href=\"https:\/\/ifttt.com\/?ref=da&#038;site=wordpress\">IFTTT<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Per the docs.Splunk entry for mstats, you can append another mstats call. So something like this should work: | mstats count(_value) as count2 WHERE metric_name=&quot;*metric2*&quot; AND metric_type=c AND status=&quot;success&quot; by metric_name,env,status | where count2=0 | append [| mstats count(_value) as count1 WHERE metric_name=&quot;*metric1*&quot; AND metric_type=c AND status=&quot;success&quot; by metric_name,env,status | where count1&gt;0 ] You should &hellip;<br \/><a href=\"https:\/\/merikebi.warrenmyers.com\/?p=61370\" class=\"more-link pen_button pen_element_default pen_icon_arrow_double\">Continue reading <span class=\"screen-reader-text\">Answer by warren for How to combine count from two different mstats in where clause Splunk?<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[991],"keyring_services":[],"class_list":["post-61370","post","type-post","status-publish","format-standard","hentry","category-blih","tag-stackexchange"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/61370","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=61370"}],"version-history":[{"count":1,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/61370\/revisions"}],"predecessor-version":[{"id":61371,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/61370\/revisions\/61371"}],"wp:attachment":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=61370"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=61370"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=61370"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fkeyring_services&post=61370"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}