{"id":61008,"date":"2022-07-26T18:52:48","date_gmt":"2022-07-26T18:52:48","guid":{"rendered":"https:\/\/merikebi.warrenmyers.com\/?p=61008"},"modified":"2022-07-26T18:52:48","modified_gmt":"2022-07-26T18:52:48","slug":"answer-by-warren-for-splunk-count-specific-string-in-a-field","status":"publish","type":"post","link":"https:\/\/merikebi.warrenmyers.com\/?p=61008","title":{"rendered":"Answer by warren for Splunk Count Specific String in a Field"},"content":{"rendered":"<p>Try this:<\/p>\n<pre><code>index=ndx sourcetype=srctp msg=*\n| rex field=msg &quot;factType=(?&lt;facttype&gt;\\w+).(?&lt;params&gt;.+)&quot;\n| stats count by facttype params\n| fields - count\n| search facttype=&quot;commercial&quot;\n<\/code><\/pre>\n<p>The <a href=\"https:\/\/docs.splunk.com\/Documentation\/Splunk\/latest\/SearchReference\/rex\" rel=\"nofollow noreferrer\"><code>rex<\/code><\/a> will extract the facttype and any following parameters (note &#8211; if the URL is submitted with the arguments in a different order, you&#8217;ll need to adjust the <a href=\"https:\/\/regex101.com\/r\/omCc6k\/1\" rel=\"nofollow noreferrer\">regular expression<\/a>)<\/p>\n<p>Then use a <code>| stats count by<\/code> to bin them together<\/p>\n<p>Lastly, search only where there is <em>both<\/em> a <code>facttype=&quot;commercial&quot;<\/code> <em>and<\/em> the URL has additional parameters<\/p>\n<p>from User warren &#8211; Stack Overflow https:\/\/stackoverflow.com\/questions\/68886885\/splunk-count-specific-string-in-a-field\/73128369#73128369<br \/>\nvia <a href=\"https:\/\/ifttt.com\/?ref=da&#038;site=wordpress\">IFTTT<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Try this: index=ndx sourcetype=srctp msg=* | rex field=msg &quot;factType=(?&lt;facttype&gt;\\w+).(?&lt;params&gt;.+)&quot; | stats count by facttype params | fields &#8211; count | search facttype=&quot;commercial&quot; The rex will extract the facttype and any following parameters (note &#8211; if the URL is submitted with the arguments in a different order, you&#8217;ll need to adjust the regular expression) Then use &hellip;<br \/><a href=\"https:\/\/merikebi.warrenmyers.com\/?p=61008\" class=\"more-link pen_button pen_element_default pen_icon_arrow_double\">Continue reading <span class=\"screen-reader-text\">Answer by warren for Splunk Count Specific String in a Field<\/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-61008","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\/61008","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=61008"}],"version-history":[{"count":1,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/61008\/revisions"}],"predecessor-version":[{"id":61009,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/61008\/revisions\/61009"}],"wp:attachment":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=61008"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=61008"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=61008"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fkeyring_services&post=61008"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}