{"id":49956,"date":"2022-01-12T17:12:25","date_gmt":"2022-01-12T17:12:25","guid":{"rendered":"https:\/\/merikebi.warrenmyers.com\/?p=49956"},"modified":"2022-01-12T17:12:25","modified_gmt":"2022-01-12T17:12:25","slug":"answer-by-warren-for-splunk-query-to-take-a-search-from-one-index-and-add-a-fields-value-from-another-index","status":"publish","type":"post","link":"https:\/\/merikebi.warrenmyers.com\/?p=49956","title":{"rendered":"Answer by warren for Splunk query to take a search from one index and add a field&#8217;s value from another index?"},"content":{"rendered":"<p>If I understand you correctly, you need to look at two different time ranges in two different indices,<\/p>\n<p>In that case, it is most likely to be true that a <a href=\"https:\/\/docs.splunk.com\/Documentation\/Splunk\/latest\/SearchReference\/join\" rel=\"nofollow noreferrer\"><code>join<\/code><\/a> will be needed<\/p>\n<p>Here&#8217;s one way it can be done:<\/p>\n<pre><code>index=ndx1 sourcetype=srctp1 field1=&quot;someval&quot; src=&quot;*&quot; earliest=-1h\n| stats count by src\n| join src\n    [| search index=ndx2 sourcetype=srctp2 field2=&quot;otherval&quot; src_ip=* src_nt_host=* earliest=-14d\n    | stats count by src_ip src_nt_host\n    | fields - count\n    | rename src_i as src ]\n<\/code><\/pre>\n<p>You may need to flip the order of the searches, depending on how many results they each return, and how long they take to run.<\/p>\n<p>You may also be able to achieve what you&#8217;re looking for in another manner <em>without<\/em> the use of a <code>join<\/code>, but we&#8217;d need to have some sample data to possibly give a better result<\/p>\n<p>from User warren &#8211; Stack Overflow https:\/\/stackoverflow.com\/questions\/70671669\/splunk-query-to-take-a-search-from-one-index-and-add-a-fields-value-from-anothe\/70685612#70685612<br \/>\nvia <a href=\"https:\/\/ifttt.com\/?ref=da&#038;site=wordpress\">IFTTT<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If I understand you correctly, you need to look at two different time ranges in two different indices, In that case, it is most likely to be true that a join will be needed Here&#8217;s one way it can be done: index=ndx1 sourcetype=srctp1 field1=&quot;someval&quot; src=&quot;*&quot; earliest=-1h | stats count by src | join src [| &hellip;<br \/><a href=\"https:\/\/merikebi.warrenmyers.com\/?p=49956\" class=\"more-link pen_button pen_element_default pen_icon_arrow_double\">Continue reading <span class=\"screen-reader-text\">Answer by warren for Splunk query to take a search from one index and add a field&#8217;s value from another index?<\/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-49956","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\/49956","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=49956"}],"version-history":[{"count":1,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/49956\/revisions"}],"predecessor-version":[{"id":49957,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/49956\/revisions\/49957"}],"wp:attachment":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=49956"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=49956"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=49956"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fkeyring_services&post=49956"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}