<?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 Conditional searching in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Conditional-searching/m-p/178313#M186780</link>
    <description>&lt;P&gt;I'm unsure how to do the following. In our environment, some clients receive private IP addresses (and are translated to public) and others receive public addresses. I need to be able to enter a public IP address and then sift through logs to find the associated mac address and username.&lt;/P&gt;

&lt;P&gt;If it's a translated public IP address, I need to FIRST check for the IP in sourcetype=firewall for src_translated_ip=&lt;PUBLICIP&gt;.&lt;/PUBLICIP&gt;&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;If it finds a result, take the associated src_ip (i.e., the private IP address) and then search in sourcetype=dhcp for the src_mac, and then map to sourcetype=auth with the src_ip and src_mac in order to get the username.&lt;/LI&gt;
&lt;LI&gt;If it does NOT find a result, use the original src_translated_ip and search with it as "src_ip" in sourcetype=dhcp for the src_mac, etc....&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;So basically, first see if it's translated; if it's not, proceed using the IP. If it is translated, find the "real" IP address, then proceed using the real IP.&lt;/P&gt;

&lt;P&gt;I have both searches figured out independently, but I want to allow for a user to simply provide the one IP address and then use if/then/else or an equivalent to do the heavy lifting.&lt;/P&gt;

&lt;P&gt;Ideas?&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 15:28:53 GMT</pubDate>
    <dc:creator>ryanholland</dc:creator>
    <dc:date>2020-09-28T15:28:53Z</dc:date>
    <item>
      <title>Conditional searching</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conditional-searching/m-p/178313#M186780</link>
      <description>&lt;P&gt;I'm unsure how to do the following. In our environment, some clients receive private IP addresses (and are translated to public) and others receive public addresses. I need to be able to enter a public IP address and then sift through logs to find the associated mac address and username.&lt;/P&gt;

&lt;P&gt;If it's a translated public IP address, I need to FIRST check for the IP in sourcetype=firewall for src_translated_ip=&lt;PUBLICIP&gt;.&lt;/PUBLICIP&gt;&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;If it finds a result, take the associated src_ip (i.e., the private IP address) and then search in sourcetype=dhcp for the src_mac, and then map to sourcetype=auth with the src_ip and src_mac in order to get the username.&lt;/LI&gt;
&lt;LI&gt;If it does NOT find a result, use the original src_translated_ip and search with it as "src_ip" in sourcetype=dhcp for the src_mac, etc....&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;So basically, first see if it's translated; if it's not, proceed using the IP. If it is translated, find the "real" IP address, then proceed using the real IP.&lt;/P&gt;

&lt;P&gt;I have both searches figured out independently, but I want to allow for a user to simply provide the one IP address and then use if/then/else or an equivalent to do the heavy lifting.&lt;/P&gt;

&lt;P&gt;Ideas?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:28:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conditional-searching/m-p/178313#M186780</guid>
      <dc:creator>ryanholland</dc:creator>
      <dc:date>2020-09-28T15:28:53Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional searching</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conditional-searching/m-p/178314#M186781</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=&amp;lt;yourindex&amp;gt; sourcetype=&amp;lt;yoursourcetype&amp;gt; | join type=outer src_translated_ip 
[search sourcetype=firewall | stats count by publicip | rename publicip as src_translated_ip 
| eval matchFouund=1 | fields - count]
|eval src_ip=case(isnoutnull(matchFound),src_ip,1=1,src_translated_ip)
|join type=outer src_ip [search sourcetype=dhcp | stats count by src_mac| fields src_mac]
|join type=outer src_ip,src_mac [search sourcetype=auth | stats count by src_ip, src_mac, username |fields - count ]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Dec 2013 18:57:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conditional-searching/m-p/178314#M186781</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2013-12-13T18:57:15Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional searching</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conditional-searching/m-p/178315#M186782</link>
      <description>&lt;P&gt;You didn't give much information about the actual log files, but I think I have pieced together this much:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=dhcp 
    [ search (sourcetype=firewall src_translated_ip="$inputip$") OR (sourcetype="what" src_ip="$inputip$")
    | eval src_ip=if(sourcetype=="firewall",src_translated_ip,src_ip)
    | fields src_ip ] 
| fields src_ip src_mac ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;CODE&gt;$inputip$&lt;/CODE&gt; represents the initial ip address. If you put this in a macro (or a form), then it will be easier to enter the inital ip, which can be either the public or private ip address.&lt;BR /&gt;&lt;BR /&gt;
This will return the public &lt;CODE&gt;src_ip&lt;/CODE&gt; and &lt;CODE&gt;src_mac&lt;/CODE&gt;. Without more information, I can't tell you how to get the username as well.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2013 15:07:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conditional-searching/m-p/178315#M186782</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-12-16T15:07:27Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional searching</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conditional-searching/m-p/178316#M186783</link>
      <description>&lt;P&gt;Thanks! The "OR" usage for sourcetype is what really kicked me off in the right direction. For whatever its worth, here's what I'm using for a macro. It takes an entered IP and port and sees if it's in the firewall logs, and if so, gets the src_ip tied to that entered IP. Then in all cases it looks for the src_ip in dhcp logs to get the mac address, then takes the IP and mac address and searches back through aruba (wireless) logs in order to find the username.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:29:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conditional-searching/m-p/178316#M186783</guid>
      <dc:creator>ryanholland</dc:creator>
      <dc:date>2020-09-28T15:29:35Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional searching</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conditional-searching/m-p/178317#M186784</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;index=my_index (sourcetype=cisco:asa src_translated_ip=$IP$ src_translated_port=$PORT$) OR (sourcetype=dhcpd src_ip=$IP$) | eval endtime=strftime(_time+300,"%m/%d/%Y:%H:%M:%S") | eval starttime=strftime(_time-300,"%m/%d/%Y:%H:%M:%S") | stats last(starttime) as starttime, first(endtime) as endtime by src_ip | map search="search index=my_index sourcetype=dhcpd starttime=$starttime$ endtime=$endtime$ src_ip=$src_ip$ dhcp_message=DHCPACK" | eval endtime=strftime(_time+300,"%m/%d/%Y:%H:%M:%S") | eval starttime=strftime(_time-86400,"%m/%d/%Y:%H:%M:%S") | stats last(starttime) as starttime, first(endtime) as endtime, by src_mac src_ip | map search="search index=my_index sourcetype=aruba_authmgr starttime=$starttime$ endtime=$endtime$ src_mac=$src_mac$ IP=$src_ip$" | stats count(_raw) by _time username MAC IP role server AP host | fields - count(_raw)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Dec 2013 18:47:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conditional-searching/m-p/178317#M186784</guid>
      <dc:creator>ryanholland</dc:creator>
      <dc:date>2013-12-16T18:47:36Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional searching</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conditional-searching/m-p/178318#M186785</link>
      <description>&lt;P&gt;Yes! I find that a lot of folks tend to use &lt;CODE&gt;join&lt;/CODE&gt; (if they have an SQL background like I do) - when &lt;CODE&gt;OR&lt;/CODE&gt; is a far better choice in Splunk.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2013 23:11:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conditional-searching/m-p/178318#M186785</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-12-16T23:11:26Z</dc:date>
    </item>
  </channel>
</rss>

