{"id":22782,"date":"2020-10-06T15:00:04","date_gmt":"2020-10-06T15:00:04","guid":{"rendered":"https:\/\/merikebi.warrenmyers.com\/?p=22782"},"modified":"2020-10-06T15:00:04","modified_gmt":"2020-10-06T15:00:04","slug":"answer-by-warren-for-how-to-do-compound-query-with-where-clause-in-splunk","status":"publish","type":"post","link":"https:\/\/merikebi.warrenmyers.com\/?p=22782","title":{"rendered":"Answer by warren for How to do compound query with where clause in Splunk?"},"content":{"rendered":"<p>Something like this should do it (presumign the fields are properly broken-out already):<\/p>\n<pre><code>index=ndx sourcetype=srctp Temperature&gt;80 \n| eval sorttime=strptime(Time,&quot;%a %B %d %Y %H:%M:%S %Z&quot;)\n| stats values(Time) as Time by strptime Location Temperature Type\n| fields - strptime\n<\/code><\/pre>\n<p><a href=\"https:\/\/docs.splunk.com\/Documentation\/Splunk\/7.0.1\/SearchReference\/DateandTimeFunctions#strptime.28X.2CY.29\" rel=\"nofollow noreferrer\"><code>strptime<\/code><\/a> will convert from your timestamp into <a href=\"https:\/\/epochconverter.com\" rel=\"nofollow noreferrer\">epoch<\/a> <a href=\"https:\/\/strftime.org\" rel=\"nofollow noreferrer\">time<\/a> &#8230; which allows for better sorting.<\/p>\n<p>That step <em>may<\/em> be unnecessary &#8211; depending on what your data <em>actually<\/em> looks like &#8211; I added it based on the sample you provided<\/p>\n<p>If you <em>also<\/em> need to parse the fields, I&#8217;ll add-onto the answer with regexes that will grab those<\/p>\n<p>from User warren &#8211; Stack Overflow https:\/\/stackoverflow.com\/questions\/64220005\/how-to-do-compound-query-with-where-clause-in-splunk\/64227546#64227546<br \/>\nvia <a href=\"https:\/\/ifttt.com\/?ref=da&#038;site=wordpress\">IFTTT<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Something like this should do it (presumign the fields are properly broken-out already): index=ndx sourcetype=srctp Temperature&gt;80 | eval sorttime=strptime(Time,&quot;%a %B %d %Y %H:%M:%S %Z&quot;) | stats values(Time) as Time by strptime Location Temperature Type | fields &#8211; strptime strptime will convert from your timestamp into epoch time &#8230; which allows for better sorting. That step &hellip;<br \/><a href=\"https:\/\/merikebi.warrenmyers.com\/?p=22782\" 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 do compound query with where clause in 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-22782","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\/22782","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=22782"}],"version-history":[{"count":1,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/22782\/revisions"}],"predecessor-version":[{"id":22784,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/22782\/revisions\/22784"}],"wp:attachment":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=22782"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=22782"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=22782"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fkeyring_services&post=22782"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}