<?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 Splunk join not working as expected in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-join-not-working-as-expected/m-p/668367#M11247</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am forwarding data from an embedded system to an enterprise instance running on a Vm. The logs look like this:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;acces_monitoring (indexed on splunk, the first empty space means still online):&lt;/LI&gt;&lt;/UL&gt;&lt;P class="lia-indent-padding-left-90px"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; Access_IP&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Access_time &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; Logoff_time&lt;BR /&gt;1 192.168.200.55 1699814895.000000&lt;BR /&gt;2 192.168.200.55 1699814004.000000 1699814060.000000&lt;BR /&gt;3 192.168.200.55 1699811754.000000 1699812677.000000&lt;BR /&gt;4 192.168.200.55 1699808364.000000 1699809475.000000&lt;BR /&gt;5 192.168.200.55 1699806635.000000 1699806681.000000&lt;BR /&gt;6 192.168.200.55 1699791222.000000 1699806628.000000&lt;BR /&gt;7 192.168.200.55 1699791125.000000 1699791127.000000&lt;BR /&gt;8 192.168.200.55 1699724540.000000 1699724541.000000&lt;BR /&gt;9 192.168.200.55 1699724390.000000 1699724474.000000&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;command_monitoring:&lt;/LI&gt;&lt;/UL&gt;&lt;P class="lia-indent-padding-left-90px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Access_IP&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exec_time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; executed_command&lt;BR /&gt;1 192.168.200.55 1699813121.000000 cd ~&lt;BR /&gt;2 192.168.200.55 1699813116.000000 cd /opt&lt;BR /&gt;3 192.168.200.55 1699813110.000000 prova3&lt;BR /&gt;4 192.168.200.55 1699811813.000000 cat sshd_config&lt;BR /&gt;5 192.168.200.55 1699811807.000000 cd /etc/ssh&lt;BR /&gt;6 192.168.200.55 1699811801.000000 cd etc&lt;BR /&gt;7 192.168.200.55 1699811793.000000 cd&lt;BR /&gt;8 192.168.200.55 1699811788.000000 ls&lt;BR /&gt;9 192.168.200.55 1699811783.000000 e che riconosce le sessioni diverse&lt;BR /&gt;10 192.168.200.55 1699811776.000000 spero funziona&lt;BR /&gt;11 192.168.200.55 1699809221.000000 cat command_log.log&lt;BR /&gt;12 192.168.200.55 1699809210.000000 ./custom_shell.sh&lt;BR /&gt;13 192.168.200.55 1699808594.000000 CD /MEDIA&lt;BR /&gt;14 192.168.200.55 1699808587.000000 cd /medi&lt;BR /&gt;15 192.168.200.55 1699808584.000000 omar&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;when i try to join the two by running:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=main source="/media/ssd1/ip_command_log/command_log.log"
| eval exec_time=strptime(exec_time, "%a %b %d %H:%M:%S %Y")
| rename ip_execut as Access_IP
| table Access_IP, exec_time, executed_command
| join type=left Access_IP
    [ search index=main source="/media/ssd1/splunk_wtmp_output.txt"
      | dedup  Access_time
      | eval Access_time=strptime(Access_time, "%a %b %d %H:%M:%S %Y")
      | eval Logoff_time=if(Logoff_time="still logged in", now(), strptime(Logoff_time, "%a %b %d %H:%M:%S %Y"))
      | table Access_IP, Access_time, Logoff_time ]
| eval session_active = if(exec_time &amp;gt;= Access_time AND exec_time &amp;lt;= coalesce(Logoff_time, now()), "true", "false")
| where session_active="true"
| table Access_IP, Access_time, Logoff_time, exec_time, executed_command&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;it does not join over every session but only the last one so the one started at 1699814895.000000 and it will not identify any of the commands ran on the embedded system in the correct session.What could be the catch?&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;Thanks in advance!&lt;/DIV&gt;</description>
    <pubDate>Sun, 12 Nov 2023 19:07:10 GMT</pubDate>
    <dc:creator>omrnuki</dc:creator>
    <dc:date>2023-11-12T19:07:10Z</dc:date>
    <item>
      <title>Splunk join not working as expected</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-join-not-working-as-expected/m-p/668367#M11247</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am forwarding data from an embedded system to an enterprise instance running on a Vm. The logs look like this:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;acces_monitoring (indexed on splunk, the first empty space means still online):&lt;/LI&gt;&lt;/UL&gt;&lt;P class="lia-indent-padding-left-90px"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; Access_IP&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Access_time &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; Logoff_time&lt;BR /&gt;1 192.168.200.55 1699814895.000000&lt;BR /&gt;2 192.168.200.55 1699814004.000000 1699814060.000000&lt;BR /&gt;3 192.168.200.55 1699811754.000000 1699812677.000000&lt;BR /&gt;4 192.168.200.55 1699808364.000000 1699809475.000000&lt;BR /&gt;5 192.168.200.55 1699806635.000000 1699806681.000000&lt;BR /&gt;6 192.168.200.55 1699791222.000000 1699806628.000000&lt;BR /&gt;7 192.168.200.55 1699791125.000000 1699791127.000000&lt;BR /&gt;8 192.168.200.55 1699724540.000000 1699724541.000000&lt;BR /&gt;9 192.168.200.55 1699724390.000000 1699724474.000000&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;command_monitoring:&lt;/LI&gt;&lt;/UL&gt;&lt;P class="lia-indent-padding-left-90px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Access_IP&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exec_time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; executed_command&lt;BR /&gt;1 192.168.200.55 1699813121.000000 cd ~&lt;BR /&gt;2 192.168.200.55 1699813116.000000 cd /opt&lt;BR /&gt;3 192.168.200.55 1699813110.000000 prova3&lt;BR /&gt;4 192.168.200.55 1699811813.000000 cat sshd_config&lt;BR /&gt;5 192.168.200.55 1699811807.000000 cd /etc/ssh&lt;BR /&gt;6 192.168.200.55 1699811801.000000 cd etc&lt;BR /&gt;7 192.168.200.55 1699811793.000000 cd&lt;BR /&gt;8 192.168.200.55 1699811788.000000 ls&lt;BR /&gt;9 192.168.200.55 1699811783.000000 e che riconosce le sessioni diverse&lt;BR /&gt;10 192.168.200.55 1699811776.000000 spero funziona&lt;BR /&gt;11 192.168.200.55 1699809221.000000 cat command_log.log&lt;BR /&gt;12 192.168.200.55 1699809210.000000 ./custom_shell.sh&lt;BR /&gt;13 192.168.200.55 1699808594.000000 CD /MEDIA&lt;BR /&gt;14 192.168.200.55 1699808587.000000 cd /medi&lt;BR /&gt;15 192.168.200.55 1699808584.000000 omar&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;when i try to join the two by running:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=main source="/media/ssd1/ip_command_log/command_log.log"
| eval exec_time=strptime(exec_time, "%a %b %d %H:%M:%S %Y")
| rename ip_execut as Access_IP
| table Access_IP, exec_time, executed_command
| join type=left Access_IP
    [ search index=main source="/media/ssd1/splunk_wtmp_output.txt"
      | dedup  Access_time
      | eval Access_time=strptime(Access_time, "%a %b %d %H:%M:%S %Y")
      | eval Logoff_time=if(Logoff_time="still logged in", now(), strptime(Logoff_time, "%a %b %d %H:%M:%S %Y"))
      | table Access_IP, Access_time, Logoff_time ]
| eval session_active = if(exec_time &amp;gt;= Access_time AND exec_time &amp;lt;= coalesce(Logoff_time, now()), "true", "false")
| where session_active="true"
| table Access_IP, Access_time, Logoff_time, exec_time, executed_command&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;it does not join over every session but only the last one so the one started at 1699814895.000000 and it will not identify any of the commands ran on the embedded system in the correct session.What could be the catch?&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;Thanks in advance!&lt;/DIV&gt;</description>
      <pubDate>Sun, 12 Nov 2023 19:07:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-join-not-working-as-expected/m-p/668367#M11247</guid>
      <dc:creator>omrnuki</dc:creator>
      <dc:date>2023-11-12T19:07:10Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk join not working as expected</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-join-not-working-as-expected/m-p/668374#M11248</link>
      <description>&lt;P&gt;Your search and your data don't match, in that you are parsing time in your SPL, but your data shows that as already in epoch time.&lt;/P&gt;&lt;P&gt;You need to use max=0 in the join statement.&lt;/P&gt;&lt;P&gt;Note that using join is not good practice, as it has a number of limitations and is slow. stats is generally the way to go, but in this case, you're effectively using the subsearch as a lookup table and are using it for a range search, but be aware.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Nov 2023 22:34:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-join-not-working-as-expected/m-p/668374#M11248</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-11-12T22:34:04Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk join not working as expected</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-join-not-working-as-expected/m-p/668403#M11249</link>
      <description>&lt;P&gt;Try something like this (to avoid joins)&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=main source="/media/ssd1/ip_command_log/command_log.log"
| eval exec_time=strptime(exec_time, "%a %b %d %H:%M:%S %Y")
| rename ip_execut as Access_IP
| table Access_IP, exec_time, executed_command
| append
    [ search index=main source="/media/ssd1/splunk_wtmp_output.txt"
      | dedup  Access_time
      | eval Access_time=strptime(Access_time, "%a %b %d %H:%M:%S %Y")
      | eval Logoff_time=if(Logoff_time="still logged in", now(), strptime(Logoff_time, "%a %b %d %H:%M:%S %Y"))
      | table Access_IP, Access_time, Logoff_time ]
| eval event_time=coalesce(Access_time, exec_time)
| sort 0 event_time
| streamstats global=f latest(Access_time) as Access_time latest(Logoff_time) as Logoff_time by Access_IP
| where exec_time&amp;gt;=Access_time AND exec_time&amp;lt;=coalesce(Logoff_time,now())
| table Access_IP, Access_time, Logoff_time, exec_time, executed_command&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 13 Nov 2023 10:02:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-join-not-working-as-expected/m-p/668403#M11249</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-11-13T10:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk join not working as expected</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-join-not-working-as-expected/m-p/668631#M11251</link>
      <description>&lt;P&gt;Thank you! The max = 0 flag is what i had missing indeed. The data i provided is the result of the search that is why it's epoch. The logs i am managing are not that big but i will keep that in mind for the future!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have a nice day!&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2023 18:17:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-join-not-working-as-expected/m-p/668631#M11251</guid>
      <dc:creator>omrnuki</dc:creator>
      <dc:date>2023-11-14T18:17:05Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk join not working as expected</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-join-not-working-as-expected/m-p/668633#M11252</link>
      <description>&lt;P&gt;Is the only advantage that append is not limited as the join?&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2023 18:29:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-join-not-working-as-expected/m-p/668633#M11252</guid>
      <dc:creator>omrnuki</dc:creator>
      <dc:date>2023-11-14T18:29:20Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk join not working as expected</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-join-not-working-as-expected/m-p/668661#M11254</link>
      <description>&lt;P&gt;In general, all subsearches have limitations, but most SQL people come to Splunk and think that join is the way to go, which is not the case. The first choice should always be to NOT use join.&lt;/P&gt;&lt;P&gt;Append will also have limits on the number of results - there are plenty of discussions on the topic and Splunk has documentation on these limits.&lt;/P&gt;&lt;P&gt;So, really, if your data size is large, you need to be aware of these limits, but also from a performance point of view, join is not the best way to go and searches using join will impact on other users on the search head.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2023 00:30:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-join-not-working-as-expected/m-p/668661#M11254</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-11-15T00:30:29Z</dc:date>
    </item>
  </channel>
</rss>

