<?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 log files from the same source path in Security</title>
    <link>https://community.splunk.com/t5/Security/JOIN-two-log-files-from-the-same-source-path/m-p/757538#M18571</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/258022"&gt;@shashankk&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think there are a couple of ways you could do this, one being:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=test_uat (source=*/DB*/scn0*/tool/log/scan*log "realtime update") OR source=*/DB*/scn0*/tool/log/output.log
| rex field=source "\/HSDB..\/(?&amp;lt;Instance&amp;gt;.*);\s" 
| rex field=_raw ":\d\d, \d\d\d;\s.*\/(?&amp;lt;vuser&amp;gt;.*);\s" 
| rex field=vuser "(?&amp;lt;UserId&amp;gt;[^/]+)$"
| eval UserId=COALESCE(UserId,user_name)
| eventstats values(cost_center) as cost_center values(first_name) as first_name, values(last_name) as last_name by UserId
| stats count by Instance, UserId, first_name, last_name, cost_center | eval {Instance}=count 
| stats values(*) AS * by UserId 
| addtotals labelfield=UserId
| fields - count Instance&lt;/LI-CODE&gt;&lt;P&gt;Another way would be to append the output.log later on, I usually try and avoid appends where possible though as they can have limitations if too many results are returned:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=test_uat source=*/DB*/scn0*/tool/log/scan*log "realtime update"
| rex field=source "\/HSDB..\/(?&amp;lt;Instance&amp;gt;.*);\s" 
| rex field=_raw ":\d\d, \d\d\d;\s.*\/(?&amp;lt;vuser&amp;gt;.*);\s" 
| rex field=vuser "(?&amp;lt;UserId&amp;gt;[^/]+)$" 
| chart count over UserId by Instance 
| addtotals labelfield=UserId 
| fillnull value=0 
| sort - Total 
| fields - count Instance 
| append 
    [ search index=test_uat source=*/DB*/scn0*/tool/log/output.log 
    | eval UserId=user_name 
    | table UserId first_name last_name cost_center] 
| stats values(*) as * by UserId&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an example of the second search using makeresults data to see it in action:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults format=csv data="_time,source, _raw
2026-01-21 12:00:01,\"/HSDB01/SCN01; \", \"123; /HSDB01/SCN01; realtime update:01, 111; some/other/path/MARVEL; x\"
        2026-01-21 12:00:02,\"/HSDB01/SCN01; \", \"234; /HSDB01/SCN01; realtime update:02, 222; some/other/path/MARVEL; x\"
        2026-01-21 12:00:03,\"/HSDB01/SCN03; \", \"345; /HSDB03/SCN03; realtime update:03, 333; some/other/path/MARVEL; x\"
        2026-01-21 12:00:04,\"/HSDB01/SCN03; \", \"456; /HSDB03/SCN03; realtime update:04, 444; some/other/path/MARVEL; x\"
        2026-01-21 12:00:05,\"/HSDB01/SCN03; \", \"567; /HSDB03/SCN03; realtime update:05, 555; some/other/path/MARVEL; x\"
        2026-01-21 12:00:06,\"/HSDB01/SCN03; \", \"678; /HSDB03/SCN03; realtime update:06, 666; some/other/path/MARVEL; x\"
        2026-01-21 12:00:07,\"/HSDB01/SCN03; \", \"789; /HSDB03/SCN03; realtime update:07, 777; some/other/path/MARVEL; x\"
        2026-01-21 12:00:08,\"/HSDB01/SCN03; \", \"890; /HSDB03/SCN03; realtime update:08, 888; some/other/path/MARVEL; x\""
    ```index=test_uat source=*/DB*/scn0*/tool/log/scan*log "realtime update"```
| rex field=source "\/HSDB..\/(?&amp;lt;Instance&amp;gt;.*);\s" 
| rex field=_raw ":\d\d, \d\d\d;\s.*\/(?&amp;lt;vuser&amp;gt;.*);\s" 
| rex field=vuser "(?&amp;lt;UserId&amp;gt;[^/]+)$" 
| chart count over UserId by Instance 
| addtotals labelfield=UserId 
| fillnull value=0 
| sort - Total 
| fields - count Instance 
| append 
    [| makeresults 
    | eval _raw="2026-01-21 08:26:45.014 user_id=\"2143\" user_name=\"MARVEL\" first_name=\"avenger\" last_name=\"superhero\" cost_center=\"DC\"" 
    | extract 
    | eval UserId=user_name 
    | table UserId first_name last_name cost_center] 
| stats values(*) as * by UserId&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="livehybrid_0-1769033985444.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/41225iF81D28016EC1FFF2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="livehybrid_0-1769033985444.png" alt="livehybrid_0-1769033985444.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":glowing_star:"&gt;🌟&lt;/span&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Did this answer help you?&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;If so, please consider:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Adding karma to show it was useful&lt;/LI&gt;&lt;LI&gt;Marking it as the solution if it resolved your issue&lt;/LI&gt;&lt;LI&gt;Commenting if you need any clarification&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Your feedback encourages the volunteers in this community to continue contributing&lt;/P&gt;</description>
    <pubDate>Wed, 21 Jan 2026 22:19:51 GMT</pubDate>
    <dc:creator>livehybrid</dc:creator>
    <dc:date>2026-01-21T22:19:51Z</dc:date>
    <item>
      <title>JOIN two log files from the same source path</title>
      <link>https://community.splunk.com/t5/Security/JOIN-two-log-files-from-the-same-source-path/m-p/757529#M18570</link>
      <description>&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;Refer &lt;SPAN&gt;below &lt;SPAN&gt;SPL &lt;SPAN&gt;query &lt;SPAN&gt;which &lt;SPAN&gt;I &lt;SPAN&gt;am &lt;SPAN&gt;using &lt;SPAN&gt;to &lt;SPAN&gt;get &lt;SPAN&gt;the &lt;STRONG&gt;UserId &lt;SPAN&gt;count &lt;SPAN&gt;against &lt;SPAN&gt;the &lt;SPAN&gt;server&amp;nbsp;&lt;STRONG&gt;I&lt;SPAN&gt;&lt;STRONG&gt;nstance.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;LI-CODE lang="markup"&gt;index=test_uat source=*/DB*/scn0*/tool/log/scan*log "realtime update"
| rex field=source "\/HSDB..\/(?&amp;lt;Instance&amp;gt;.*);\s"
| rex ":\d\d, \d\d\d;\s.*\/(?&amp;lt;vuser&amp;gt;.*);\s"
| rex field vuser "(?&amp;lt;UserId&amp;gt;[^/]+)$"
| chart count over UserId by Instance
| addtotals lablefield=UserId
| fillnull value=0
| sort - Total&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;SPAN&gt;This &lt;SPAN&gt;gives &lt;SPAN&gt;output &lt;SPAN&gt;as &lt;SPAN&gt;&lt;SPAN&gt;below:&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;LI-CODE lang="markup"&gt;UserId, scn01, scn02, scn03, Total
MARVEL, 2, 0, 6, 8&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I &lt;/SPAN&gt;&lt;SPAN&gt;am&lt;/SPAN&gt; &lt;SPAN&gt;having&lt;/SPAN&gt; &lt;SPAN&gt;2&lt;/SPAN&gt; &lt;SPAN&gt;source&lt;/SPAN&gt; &lt;SPAN&gt;files&lt;/SPAN&gt; &lt;SPAN&gt;on&lt;/SPAN&gt; &lt;SPAN&gt;the&lt;/SPAN&gt; &lt;SPAN&gt;same&lt;/SPAN&gt; &lt;SPAN&gt;&lt;SPAN&gt;path.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;source=*/DB*/scn0*/tool/log/scan.log&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;source=*/DB*/scn0*/tool/log/output.log&lt;/STRONG&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;which &lt;/SPAN&gt;&lt;SPAN&gt;I can combine and use as below:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;LI-CODE lang="markup"&gt;source=*/DB*/scn0*/tool/log/*log&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;STRONG&gt;Sample event log from "output.log"&lt;/STRONG&gt;&lt;/DIV&gt;&lt;LI-CODE lang="markup"&gt;2026-01-21 08:26:45.014 user_id="2143" user_name="MARVEL" first_name="avenger" last_name="superhero" cost_center="DC"&lt;/LI-CODE&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;The common field between the 2 logs is &lt;STRONG&gt;"UserId = user_name"&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;Based on this join, I want to show the final output as below:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;UserId, first_name, last_name, cost_center, scn01, scn02, scn03, Total&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;MARVEL, avenger, superhero, DC, 2, 0, 6, 8&lt;/STRONG&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;SPAN&gt;&lt;BR /&gt;Please &lt;SPAN&gt;help &lt;SPAN&gt;with &lt;SPAN&gt;this &lt;SPAN&gt;join &lt;SPAN&gt;and &lt;SPAN&gt;suggest &lt;SPAN&gt;the &lt;SPAN&gt;updated &lt;SPAN&gt;query.&lt;BR /&gt;&lt;BR /&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 21 Jan 2026 18:26:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/JOIN-two-log-files-from-the-same-source-path/m-p/757529#M18570</guid>
      <dc:creator>shashankk</dc:creator>
      <dc:date>2026-01-21T18:26:59Z</dc:date>
    </item>
    <item>
      <title>Re: JOIN two log files from the same source path</title>
      <link>https://community.splunk.com/t5/Security/JOIN-two-log-files-from-the-same-source-path/m-p/757538#M18571</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/258022"&gt;@shashankk&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think there are a couple of ways you could do this, one being:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=test_uat (source=*/DB*/scn0*/tool/log/scan*log "realtime update") OR source=*/DB*/scn0*/tool/log/output.log
| rex field=source "\/HSDB..\/(?&amp;lt;Instance&amp;gt;.*);\s" 
| rex field=_raw ":\d\d, \d\d\d;\s.*\/(?&amp;lt;vuser&amp;gt;.*);\s" 
| rex field=vuser "(?&amp;lt;UserId&amp;gt;[^/]+)$"
| eval UserId=COALESCE(UserId,user_name)
| eventstats values(cost_center) as cost_center values(first_name) as first_name, values(last_name) as last_name by UserId
| stats count by Instance, UserId, first_name, last_name, cost_center | eval {Instance}=count 
| stats values(*) AS * by UserId 
| addtotals labelfield=UserId
| fields - count Instance&lt;/LI-CODE&gt;&lt;P&gt;Another way would be to append the output.log later on, I usually try and avoid appends where possible though as they can have limitations if too many results are returned:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=test_uat source=*/DB*/scn0*/tool/log/scan*log "realtime update"
| rex field=source "\/HSDB..\/(?&amp;lt;Instance&amp;gt;.*);\s" 
| rex field=_raw ":\d\d, \d\d\d;\s.*\/(?&amp;lt;vuser&amp;gt;.*);\s" 
| rex field=vuser "(?&amp;lt;UserId&amp;gt;[^/]+)$" 
| chart count over UserId by Instance 
| addtotals labelfield=UserId 
| fillnull value=0 
| sort - Total 
| fields - count Instance 
| append 
    [ search index=test_uat source=*/DB*/scn0*/tool/log/output.log 
    | eval UserId=user_name 
    | table UserId first_name last_name cost_center] 
| stats values(*) as * by UserId&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an example of the second search using makeresults data to see it in action:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults format=csv data="_time,source, _raw
2026-01-21 12:00:01,\"/HSDB01/SCN01; \", \"123; /HSDB01/SCN01; realtime update:01, 111; some/other/path/MARVEL; x\"
        2026-01-21 12:00:02,\"/HSDB01/SCN01; \", \"234; /HSDB01/SCN01; realtime update:02, 222; some/other/path/MARVEL; x\"
        2026-01-21 12:00:03,\"/HSDB01/SCN03; \", \"345; /HSDB03/SCN03; realtime update:03, 333; some/other/path/MARVEL; x\"
        2026-01-21 12:00:04,\"/HSDB01/SCN03; \", \"456; /HSDB03/SCN03; realtime update:04, 444; some/other/path/MARVEL; x\"
        2026-01-21 12:00:05,\"/HSDB01/SCN03; \", \"567; /HSDB03/SCN03; realtime update:05, 555; some/other/path/MARVEL; x\"
        2026-01-21 12:00:06,\"/HSDB01/SCN03; \", \"678; /HSDB03/SCN03; realtime update:06, 666; some/other/path/MARVEL; x\"
        2026-01-21 12:00:07,\"/HSDB01/SCN03; \", \"789; /HSDB03/SCN03; realtime update:07, 777; some/other/path/MARVEL; x\"
        2026-01-21 12:00:08,\"/HSDB01/SCN03; \", \"890; /HSDB03/SCN03; realtime update:08, 888; some/other/path/MARVEL; x\""
    ```index=test_uat source=*/DB*/scn0*/tool/log/scan*log "realtime update"```
| rex field=source "\/HSDB..\/(?&amp;lt;Instance&amp;gt;.*);\s" 
| rex field=_raw ":\d\d, \d\d\d;\s.*\/(?&amp;lt;vuser&amp;gt;.*);\s" 
| rex field=vuser "(?&amp;lt;UserId&amp;gt;[^/]+)$" 
| chart count over UserId by Instance 
| addtotals labelfield=UserId 
| fillnull value=0 
| sort - Total 
| fields - count Instance 
| append 
    [| makeresults 
    | eval _raw="2026-01-21 08:26:45.014 user_id=\"2143\" user_name=\"MARVEL\" first_name=\"avenger\" last_name=\"superhero\" cost_center=\"DC\"" 
    | extract 
    | eval UserId=user_name 
    | table UserId first_name last_name cost_center] 
| stats values(*) as * by UserId&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="livehybrid_0-1769033985444.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/41225iF81D28016EC1FFF2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="livehybrid_0-1769033985444.png" alt="livehybrid_0-1769033985444.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":glowing_star:"&gt;🌟&lt;/span&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Did this answer help you?&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;If so, please consider:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Adding karma to show it was useful&lt;/LI&gt;&lt;LI&gt;Marking it as the solution if it resolved your issue&lt;/LI&gt;&lt;LI&gt;Commenting if you need any clarification&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Your feedback encourages the volunteers in this community to continue contributing&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jan 2026 22:19:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/JOIN-two-log-files-from-the-same-source-path/m-p/757538#M18571</guid>
      <dc:creator>livehybrid</dc:creator>
      <dc:date>2026-01-21T22:19:51Z</dc:date>
    </item>
    <item>
      <title>Re: JOIN two log files from the same source path</title>
      <link>https://community.splunk.com/t5/Security/JOIN-two-log-files-from-the-same-source-path/m-p/757541#M18572</link>
      <description>&lt;P&gt;The way to get that final output is to create a composite field of the UserId, first_name, last_name and cost centre and then use xyseries to turn that around having used stats, not chart.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;... both data sets feed into this ```
``` Gets the user info from output.log data ```
| rex "user_name=\"(?&amp;lt;UserId&amp;gt;[^\"]*)\".*first_name=\"(?&amp;lt;first_name&amp;gt;[^\"]*)\".*last_name=\"(?&amp;lt;last_name&amp;gt;[^\"]*)\".*cost_center=\"(?&amp;lt;cost_centre&amp;gt;[^\"]*)\""

``` Only count the scan.log events ```
| eval is_counted=if(match(source, "scan.log$"), 1, 0)
``` Now use stats to collect all values of these fields ```
| fields UserId first_name last_name cost_center Instance is_counted
| stats values(*) as * sum(is_counted) as count by UserId Instance

``` Create the composite key ```
| eval identity=UserId."##".first_name."##".last_name."##".cost_centre
``` Turn the table around like chart ```
| xyseries identity Instance count 
``` And now break out that composite field again ```
| rex field=identity "(?&amp;lt;UserId&amp;gt;.*)##(?&amp;lt;first_name&amp;gt;.*)##(?&amp;lt;last_name&amp;gt;.*)##(?&amp;lt;cost_centre&amp;gt;.*)"
| fields - identity&lt;/LI-CODE&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jan 2026 23:05:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/JOIN-two-log-files-from-the-same-source-path/m-p/757541#M18572</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2026-01-21T23:05:43Z</dc:date>
    </item>
  </channel>
</rss>

