<?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: Correlation of two searches in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Correlation-of-two-searches/m-p/547684#M155309</link>
    <description>&lt;P&gt;Something like this can accomplish what you're trying to do. You can eliminate the need to rename in the search if you normalize your data (e.g. create a field alias that aliases Source_Address to src_ip).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(index=estreamer src_ip!="10.0.0.0/8" src_ip!="192.168.0.0/24" src_ip!=172.16.0.0/12 (app_proto="TeamViewer" app_proto="FTP" OR app_proto="FTP Data" OR app_proto="Telnet" OR app_proto="RDP" OR app_proto="SSH" OR dest_port="3389" OR dest_port="23" OR dest_port="22") fw_rule_action="Allow") OR (index=windows source=wineventlog EventCode IN ("5154","5156") Source_Address!="10.0.0.0/8" Source_Address!="192.168.0.0/24" Source_Address!="172.16.0.0/12") | rename Source_Address as src_ip | stats values(somefield) as somefield, values(someotherfield) as someotherfield by src_ip&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 12 Apr 2021 22:40:58 GMT</pubDate>
    <dc:creator>ericjorgensenjr</dc:creator>
    <dc:date>2021-04-12T22:40:58Z</dc:date>
    <item>
      <title>Correlation of two searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Correlation-of-two-searches/m-p/547633#M155299</link>
      <description>&lt;P&gt;Good day Community,&lt;BR /&gt;&lt;BR /&gt;I would like to know what is the best approach to filters events based on previous query. My precisely here is my scenario:&lt;/P&gt;&lt;P&gt;I am attempting to correlate our firewall logs against Windows Event Log 5156 / 5154 which is the local firewall that allowed a connection.&lt;/P&gt;&lt;P&gt;I am not sure if a multi-search is the best approach, or using append vs join vs subsearch. Did anyone ever crafted a SPL similar to the one describe above, or can provide some insight into the best method to achieve the results wanted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;</description>
      <pubDate>Mon, 12 Apr 2021 15:59:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Correlation-of-two-searches/m-p/547633#M155299</guid>
      <dc:creator>Habanero</dc:creator>
      <dc:date>2021-04-12T15:59:47Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation of two searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Correlation-of-two-searches/m-p/547636#M155300</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231252"&gt;@Habanero&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;in general, if you can, avoid join command because it's a very slow command, in addition has the limit (as all the subsearches) of 50,000 results.&lt;/P&gt;&lt;P&gt;So you have to know two thing:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;the secondary search could have more or less than 50,000 results?&lt;/LI&gt;&lt;LI&gt;do you need some informations from the secondary search or you need only to filter the primary search?&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;knowing these two things you can choos the best solution for your need:&lt;/P&gt;&lt;P&gt;if you need to filter the results of the first search using the second one and you have less than 50,000 results in the subsearch you can run something like this:&lt;/P&gt;&lt;P&gt;e.g. searching host in index1 that are also present in index1:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=index1 [ search index=index2 | dedup host | fields host ]
| ...&lt;/LI-CODE&gt;&lt;P&gt;the only rule is that the field names must be the same in main and secondary search.&lt;/P&gt;&lt;P&gt;If instead the results in secondary search are more than 50,000, you cannot use subsearch and you have to correlate them, something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=index1 OR index=index2
| stats dc(index) AS count BY index
| where count=2&lt;/LI-CODE&gt;&lt;P&gt;if you need to take fields from index1 and from index2, you have to run something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=index1 OR index=index2
| stats values(field1.1) As field1.1 values(field1.2) As field1.2 values(field2.1) As field12.1 values(field2.2) As field12.2 BY index&lt;/LI-CODE&gt;&lt;P&gt;i hope to be clear.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 12 Apr 2021 16:20:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Correlation-of-two-searches/m-p/547636#M155300</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2021-04-12T16:20:04Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation of two searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Correlation-of-two-searches/m-p/547642#M155301</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;for the prompt reply.&lt;BR /&gt;&lt;BR /&gt;It cleared up some questions in regards to the limitation.&lt;/P&gt;&lt;P&gt;One of the issues are the fact that both index does not have the same name field.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;For instance this is the SPL for my first search.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=estreamer src_ip!="10.0.0.0/8" src_ip!="192.168.0.0/24" src_ip!=172.16.0.0/12 (app_proto="TeamViewer" app_proto="FTP" OR app_proto="FTP Data" OR app_proto="Telnet" OR app_proto="RDP" OR app_proto="SSH" OR dest_port="3389" OR dest_port="23" OR dest_port="22") fw_rule_action="Allow"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The event of interest I am seeking are IP addresses that were allowed by the firewall and opened connection on our Windows servers (EventCode 5154/5156)&lt;/P&gt;&lt;P&gt;Our firewall uses the field name `&lt;STRONG&gt;src_ip&lt;/STRONG&gt;` and Windows Event are `&lt;STRONG&gt;Source_Address&lt;/STRONG&gt;`&lt;/P&gt;&lt;P&gt;If I understand I would have to rename the field to be able to search against our Windows Index&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rename src_ip as Source_Address&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Apr 2021 17:52:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Correlation-of-two-searches/m-p/547642#M155301</guid>
      <dc:creator>Habanero</dc:creator>
      <dc:date>2021-04-12T17:52:53Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation of two searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Correlation-of-two-searches/m-p/547684#M155309</link>
      <description>&lt;P&gt;Something like this can accomplish what you're trying to do. You can eliminate the need to rename in the search if you normalize your data (e.g. create a field alias that aliases Source_Address to src_ip).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(index=estreamer src_ip!="10.0.0.0/8" src_ip!="192.168.0.0/24" src_ip!=172.16.0.0/12 (app_proto="TeamViewer" app_proto="FTP" OR app_proto="FTP Data" OR app_proto="Telnet" OR app_proto="RDP" OR app_proto="SSH" OR dest_port="3389" OR dest_port="23" OR dest_port="22") fw_rule_action="Allow") OR (index=windows source=wineventlog EventCode IN ("5154","5156") Source_Address!="10.0.0.0/8" Source_Address!="192.168.0.0/24" Source_Address!="172.16.0.0/12") | rename Source_Address as src_ip | stats values(somefield) as somefield, values(someotherfield) as someotherfield by src_ip&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Apr 2021 22:40:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Correlation-of-two-searches/m-p/547684#M155309</guid>
      <dc:creator>ericjorgensenjr</dc:creator>
      <dc:date>2021-04-12T22:40:58Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation of two searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Correlation-of-two-searches/m-p/547718#M155324</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231252"&gt;@Habanero&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;yes, the main action you have to do is to rename one of the fields to have the same fieldname in both the partial searches.&lt;/P&gt;&lt;P&gt;You have to do this in both the cases: if you have to perform a subsearch or if you have to correlate searches with stats command.&lt;/P&gt;&lt;P&gt;So, you have to run something like this:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=estreamer NOT (src_ip="10.0.0.0/8" OR src_ip="192.168.0.0/24" OR src_ip=172.16.0.0/12) (app_proto="TeamViewer" OR app_proto="FTP" OR app_proto="FTP Data" OR app_proto="Telnet" OR app_proto="RDP" OR app_proto="SSH" OR dest_port="3389" OR dest_port="23" OR dest_port="22") fw_rule_action="Allow" [ search index=wineventlog | rename Source_Address AS src_ip | fields src_ip ]
| ...&lt;/LI-CODE&gt;&lt;P&gt;Only two little final notes: you forgot one OR in the parenthesis conditions and it's better to have a NOT = condition than a != condition.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 06:39:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Correlation-of-two-searches/m-p/547718#M155324</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2021-04-13T06:39:56Z</dc:date>
    </item>
  </channel>
</rss>

