<?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: Join Two Searches on Shared Field Value in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Join-Two-Searches-on-Shared-Field-Value/m-p/676637#M231397</link>
    <description>&lt;P&gt;I figured out the issue. The API fields needed to be double quoted or the reference broke. I assume it has something to do with the message being a JSON object. Outside of that minor syntax issue, your solution worked. Thank you!&lt;/P&gt;</description>
    <pubDate>Mon, 05 Feb 2024 19:43:13 GMT</pubDate>
    <dc:creator>lhillscu</dc:creator>
    <dc:date>2024-02-05T19:43:13Z</dc:date>
    <item>
      <title>Join Two Searches on Shared Field Value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-Two-Searches-on-Shared-Field-Value/m-p/676408#M231343</link>
      <description>&lt;P&gt;I have an index that contains all the hits for our WAF and an index that contains the subsequent API call details for any of those hits that are an application calling one our APIs behind the WAF. There is a shared identifier that the WAF passes to the API call so we can link them together and see what IP, user agent string, etc. made that API call. I am trying to pull data from both indexes together into a nice table so that our devs and our security folks can see what API calls are being made, who/what is calling them, and the payloads.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;API search:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=api source=api_call
| rename id as sessionID
| fields apiName, payload, sessionID&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;WAF search:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=waf
| fields src_ip, requestHost, requestPath, requestUserAgent, sessionID&lt;/LI-CODE&gt;
&lt;P&gt;My attempt to join them on the sessionID which is not working. It returns no results.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=api source=api_call
| rename message.id as sessionID
| fields apiName, message.payload, sessionID
| join sessionID
          [search index=waf
            | fields src_ip, requestHost, requestPath, requestUserAgent, sessionID]
| table apiName, message.payload, sessionID, src_ip, requestHost, requestPath, requestUserAgent&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;I know joins are not very performative, so I'm open to alternatives that don't use it, but I'm not sure what those would be.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 16:59:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-Two-Searches-on-Shared-Field-Value/m-p/676408#M231343</guid>
      <dc:creator>lhillscu</dc:creator>
      <dc:date>2024-02-02T16:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: Join Two Searches on Shared Field Value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-Two-Searches-on-Shared-Field-Value/m-p/676414#M231345</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/246606"&gt;@lhillscu&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Your query seems correct. Could you please confirm that these 2 fields really exists in the last query? Since these 2 fields were not referenced in the "API Search" example.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;message.id
message.payload&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 17:48:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-Two-Searches-on-Shared-Field-Value/m-p/676414#M231345</guid>
      <dc:creator>danielcj</dc:creator>
      <dc:date>2024-02-02T17:48:38Z</dc:date>
    </item>
    <item>
      <title>Re: Join Two Searches on Shared Field Value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-Two-Searches-on-Shared-Field-Value/m-p/676416#M231346</link>
      <description>&lt;P&gt;I think this will work without using &lt;FONT face="courier new,courier"&gt;join&lt;/FONT&gt;.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(index=api source=api_call) OR index=waf
| eval sessionID=coalesce(sessionID, message.id)
| fields apiName, message.payload, sessionID,src_ip, requestHost, requestPath, requestUserAgent
| stats values(*) as * by sessionID
| table apiName, message.payload, sessionID, src_ip, requestHost, requestPath, requestUserAgent&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 17:56:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-Two-Searches-on-Shared-Field-Value/m-p/676416#M231346</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2024-02-02T17:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: Join Two Searches on Shared Field Value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-Two-Searches-on-Shared-Field-Value/m-p/676424#M231351</link>
      <description>&lt;P&gt;I now get almost 2 million events, which is about all the events in the WAF log for yesterday, but no table of results. I know that yesterday there was 1 connection through the WAF which produced 6 API calls (one primary and then several downstream). So the number of lines in my table should be 6.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 18:33:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-Two-Searches-on-Shared-Field-Value/m-p/676424#M231351</guid>
      <dc:creator>lhillscu</dc:creator>
      <dc:date>2024-02-02T18:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: Join Two Searches on Shared Field Value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-Two-Searches-on-Shared-Field-Value/m-p/676425#M231352</link>
      <description>&lt;P&gt;Apologies I took out all the extra renames to try to simplify the search since those aren't really critical to the data I'm trying to get. The fields are actually as they are named in the full search with the join. First search thus should be:&lt;BR /&gt;&lt;BR /&gt;index=api source=api_call&lt;BR /&gt;| rename id as sessionID&lt;BR /&gt;| fields apiName, message.payload, sessionID&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 18:36:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-Two-Searches-on-Shared-Field-Value/m-p/676425#M231352</guid>
      <dc:creator>lhillscu</dc:creator>
      <dc:date>2024-02-02T18:36:35Z</dc:date>
    </item>
    <item>
      <title>Re: Join Two Searches on Shared Field Value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-Two-Searches-on-Shared-Field-Value/m-p/676444#M231359</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;'s solution should give the correct results and is more efficient. &amp;nbsp;But you need to clarify&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213178"&gt;@danielcj&lt;/a&gt;'s question thoroughly. &amp;nbsp;In &lt;A href="https://community.splunk.com/t5/Splunk-Search/Join-Two-Searches-on-Shared-Field-Value/m-p/676425/highlight/true#M231352" target="_self"&gt;your response&lt;/A&gt;, you reprinted&amp;nbsp;&lt;FONT face="courier new,courier"&gt;| rename id as sessionID&lt;/FONT&gt; as in the first part of your original post, which contradicts the second part of your original post where&amp;nbsp;&lt;FONT face="courier new,courier"&gt;| rename message.id as sessionID&lt;/FONT&gt; is printed. &amp;nbsp;Does index &lt;EM&gt;api&lt;/EM&gt; give&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;FONT face="courier new,courier"&gt;id&lt;/FONT&gt;, or&lt;/LI&gt;&lt;LI&gt;&lt;FONT face="courier new,courier"&gt;message.id&lt;/FONT&gt;, or&lt;/LI&gt;&lt;LI&gt;both but only one of them should be used as &lt;FONT face="courier new,courier"&gt;sessionID&lt;/FONT&gt;?&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;'s solution should work in case 2. &amp;nbsp;If index api gives &lt;FONT face="courier new,courier"&gt;id&lt;/FONT&gt;&amp;nbsp;(or if it gives both but only &lt;FONT face="courier new,courier"&gt;id&lt;/FONT&gt; should be used in match) - which the first part of your original post and your reply to&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213178"&gt;@danielcj&lt;/a&gt;&amp;nbsp;imply, the solution can easily be adapted to&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(index=api source=api_call) OR index=waf
| fields id apiName, message.payload, src_ip, requestHost, requestPath, requestUserAgent, sessionID
| eval sessionID = coalesce(sessionID, id)
| stats values(*) as * by sessionID&lt;/LI-CODE&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 22:18:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-Two-Searches-on-Shared-Field-Value/m-p/676444#M231359</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-02-02T22:18:26Z</dc:date>
    </item>
    <item>
      <title>Re: Join Two Searches on Shared Field Value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-Two-Searches-on-Shared-Field-Value/m-p/676599#M231388</link>
      <description>&lt;P&gt;It's message.id. There is a JSON object called message that has a number of fields in it. message.id gets the WAF session id value.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Feb 2024 15:04:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-Two-Searches-on-Shared-Field-Value/m-p/676599#M231388</guid>
      <dc:creator>lhillscu</dc:creator>
      <dc:date>2024-02-05T15:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: Join Two Searches on Shared Field Value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-Two-Searches-on-Shared-Field-Value/m-p/676637#M231397</link>
      <description>&lt;P&gt;I figured out the issue. The API fields needed to be double quoted or the reference broke. I assume it has something to do with the message being a JSON object. Outside of that minor syntax issue, your solution worked. Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 05 Feb 2024 19:43:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-Two-Searches-on-Shared-Field-Value/m-p/676637#M231397</guid>
      <dc:creator>lhillscu</dc:creator>
      <dc:date>2024-02-05T19:43:13Z</dc:date>
    </item>
    <item>
      <title>Re: Join Two Searches on Shared Field Value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-Two-Searches-on-Shared-Field-Value/m-p/676685#M231413</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;I figured out the issue. The API fields needed to be double quoted or the reference broke. I assume it has something to do with the message being a JSON object. Outside of that minor syntax issue, your solution worked. Thank you!&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Actually, the need for quote is because field names contain a &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/Search/Eventsegmentationandsearching#Major_breakers" target="_blank" rel="noopener"&gt;major breaker&lt;/A&gt;&amp;nbsp;dot ("."). &amp;nbsp;I should have spotted this given that I just wrote &lt;A href="https://wordpress.com/post/whackyhack.wordpress.com/155" target="_blank" rel="noopener"&gt;Single Quotes, Double Quotes, or No Quotes (SPL)&lt;/A&gt;&amp;nbsp;for people who want to confront the wonkiness of SPL's quote rules.&amp;nbsp; Here, you need to use single quote, not double quote. &amp;nbsp;And you only need it inside &lt;FONT face="courier new,courier"&gt;coalesce&lt;/FONT&gt;.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(index=api source=api_call) OR index=waf
| eval sessionID=coalesce(sessionID, 'message.id')
| fields apiName, message.payload, sessionID,src_ip, requestHost, requestPath, requestUserAgent
| stats values(*) as * by sessionID
| table apiName, message.payload, sessionID, src_ip, requestHost, requestPath, requestUserAgent&lt;/LI-CODE&gt;&lt;P&gt;Though technically you can use double quotes around &lt;FONT face="terminal,monaco"&gt;&lt;EM&gt;message.id&lt;/EM&gt;&lt;/FONT&gt; in &lt;FONT face="courier new,courier"&gt;rename&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;fields&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;stats&lt;/FONT&gt;, and &lt;FONT face="courier new,courier"&gt;table&lt;/FONT&gt; commands, they are not necessary. &amp;nbsp;But if you use "message.id" in coalesce, sessionID will get the literal string "message.id"&amp;nbsp;as value for events from index api.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2024 04:43:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-Two-Searches-on-Shared-Field-Value/m-p/676685#M231413</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-02-06T04:43:24Z</dc:date>
    </item>
  </channel>
</rss>

