<?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: sub-search search query in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/sub-search-search-query/m-p/28646#M5705</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;I have a simple sub search working for IP addresses,&lt;/P&gt;

&lt;P&gt;source="/var/log/iptables.log" [search source="/var/log/iptables.log" SRC!=192.168.* | top SRC limit=1 | fields SRC] &lt;/P&gt;

&lt;P&gt;Is that pipe before your sub string causing the issue?&lt;/P&gt;</description>
    <pubDate>Fri, 13 Aug 2010 22:30:03 GMT</pubDate>
    <dc:creator>Pete_Bassill</dc:creator>
    <dc:date>2010-08-13T22:30:03Z</dc:date>
    <item>
      <title>sub-search search query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sub-search-search-query/m-p/28645#M5704</link>
      <description>&lt;P&gt;I'm trying to run a search query like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=linux1 DHCPACK | rex field=_raw "on (?&amp;lt;ip&amp;gt;.*) to (?&amp;lt;mac&amp;gt;.*)" | [search host="node1" OR host="stadc01" OR host="stadc02" &amp;lt;&amp;lt;username  goes here&amp;gt;&amp;gt; EventCode=540 | top limit=1 Source_Network_Address | fields + Source_Network_Address] 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Which finds the latest login from the given username, extracts the ip address from the event log, and then finds and returns the mac address via some DHCP logs (matching the IPs) this is so that we can find the physical location of the machine. It's giving me various errors, however- not to mention that the current query is incomplete. Any ideas to get the query working right? Thanks for the help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Example DHCP entry: &lt;/P&gt;

&lt;P&gt;8/11/10
2:29:19.000 PM  &lt;/P&gt;

&lt;P&gt;Aug 11 14:29:19 linux1 dhcpd: DHCPACK on 10.182.171.65 to 00:xx:12:xx:x0:xc via 10.182.171.2&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;* host=linux1   Options|  
* sourcetype=syslog   Options|  
* source=/var/log/syslog   Options
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Example EventLog login entry:&lt;/P&gt;

&lt;P&gt;8/11/10
2:36:03.000 PM  &lt;/P&gt;

&lt;P&gt;08/11/10 02:36:03 PM
LogName=Security
SourceName=Security
EventCode=540
EventType=8
Type=Success Audit
ComputerName=DC02
User=&amp;lt;&amp;gt;
Sid=S-1-5-21-767897961-102478171-4665678964-895678
SidType=1
Category=2
CategoryString=Logon/Logoff
RecordNumber=1384567698
Message=Successful Network Logon:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;User Name:  &amp;lt;&amp;lt;USERNAME&amp;gt;&amp;gt;

Domain:     STAFF

Logon ID:       (0x0,0x1E1EA75)

Logon Type: 3

Logon Process:  Kerberos

Authentication Package: Kerberos

Workstation Name:   

Logon GUID: {9e4539d92-ba06-83435-22td-9ddsfg45b23ec8}

Caller User Name:   -

Caller Domain:  -

Caller Logon ID:    -

Caller Process ID: -

Transited Services: -

Source Network Address: 10.1.23.123

Source Port:    0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Collapse back to 10 lines&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;* host=dc2   Options|  
* sourcetype=WinEventLog:Security   Options|  
* source=WinEventLog:Security   Options|  
* linecount=45   Options|  
* splunk_server=logger   Options|  
* index=main   Options
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Attempted search query (part of the one above):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=linux1 DHCPACK | rex field=_raw "on (?&amp;lt;ip&amp;gt;.*) to (?&amp;lt;mac&amp;gt;.*)" 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Aug 2010 04:46:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sub-search-search-query/m-p/28645#M5704</guid>
      <dc:creator>lelanb</dc:creator>
      <dc:date>2010-08-12T04:46:53Z</dc:date>
    </item>
    <item>
      <title>Re: sub-search search query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sub-search-search-query/m-p/28646#M5705</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;I have a simple sub search working for IP addresses,&lt;/P&gt;

&lt;P&gt;source="/var/log/iptables.log" [search source="/var/log/iptables.log" SRC!=192.168.* | top SRC limit=1 | fields SRC] &lt;/P&gt;

&lt;P&gt;Is that pipe before your sub string causing the issue?&lt;/P&gt;</description>
      <pubDate>Fri, 13 Aug 2010 22:30:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sub-search-search-query/m-p/28646#M5705</guid>
      <dc:creator>Pete_Bassill</dc:creator>
      <dc:date>2010-08-13T22:30:03Z</dc:date>
    </item>
    <item>
      <title>Re: sub-search search query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sub-search-search-query/m-p/28647#M5706</link>
      <description>&lt;P&gt;Your search is nearly correct. You just need to tell Splunk that you want the output of the subsearch to be an argument to the search command and also that the Source_Network_Address field should be called "ip" in the outer search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=linux1 DHCPACK | rex field=_raw "on (?&amp;lt;ip&amp;gt;.*) to (?&amp;lt;mac&amp;gt;.*)" | search [search host="node1" OR host="stadc01" OR host="stadc02" &amp;lt;&amp;lt;username  goes here&amp;gt;&amp;gt; EventCode=540 | top limit=1 Source_Network_Address | fields Source_Network_Address | rename Source_Network_Address as ip]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now if you configure an automatic extraction in props.conf for this data say:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[source::/var/log/syslog]
EXTRACT-dhcp = DHCPACK on (?&amp;lt;ip&amp;gt;.*) to (?&amp;lt;mac&amp;gt;.*)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then your search can be much shorter, and faster as well, since we can use the index to look for the ip, rather than perform a full table scan:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=linux1 DHCPACK [search host="node1" OR host="stadc01" OR host="stadc02" &amp;lt;&amp;lt;username  goes here&amp;gt;&amp;gt; EventCode=540 | top limit=1 Source_Network_Address | fields Source_Network_Address | rename Source_Network_Address as ip]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 21 Aug 2010 05:40:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sub-search-search-query/m-p/28647#M5706</guid>
      <dc:creator>Stephen_Sorkin</dc:creator>
      <dc:date>2010-08-21T05:40:50Z</dc:date>
    </item>
    <item>
      <title>Re: sub-search search query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sub-search-search-query/m-p/28648#M5707</link>
      <description>&lt;P&gt;Ah, thanks. I already got similar functionality using a join statement, but the auto-extraction looks like it would work even better.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Aug 2010 01:16:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sub-search-search-query/m-p/28648#M5707</guid>
      <dc:creator>lelanb</dc:creator>
      <dc:date>2010-08-27T01:16:00Z</dc:date>
    </item>
  </channel>
</rss>

