<?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: Help with subsearch in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Help-with-subsearch/m-p/444872#M126162</link>
    <description>&lt;P&gt;It was the problem! thanks nvanderwalt ,you are the man!&lt;/P&gt;</description>
    <pubDate>Mon, 01 Jul 2019 17:01:23 GMT</pubDate>
    <dc:creator>lucasdc</dc:creator>
    <dc:date>2019-07-01T17:01:23Z</dc:date>
    <item>
      <title>Help with subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-subsearch/m-p/444868#M126158</link>
      <description>&lt;P&gt;I have this search 1:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=br_activedirectory_microsoft EventCode=4624 Account_Domain=AGBANESPA Account_Name=A* 
 | fields Account_Domain, Account_Name, Source_Network_Address
 | dedup Account_Domain, Account_Name, Source_Network_Address
 | lookup dnslookup clientip as Source_Network_Address OUTPUT clienthost
 | eval user = substr(mvindex(Account_Name,1),2,4)
 | eval hostname = substr(clienthost,3,4)
 | where user !=hostname
 | lookup new_hostname_lookup hostname as hostname OUTPUT ENDEREÇO, UF, REG, CEP , REDE
 | lookup new_user_lookup user as user OUTPUT ENDEREÇO_user, UF_user, REG_user, CEP_user ,REDE_user
 | where REG !=REG_user AND REDE !=REDE_user
 | table Account_Name
 | rename Account_Name as "Siglas dos usúarios com acessos indevidos"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and I have this search 2:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="br_activedirectory_microsoft"  EventCode=4624 OR EventCode=4634 Account_Name=A* Account_Domain=AGBANESPA
 | search NOT (Account_Name=$$ OR Account_Name=SYSTEM OR Account_Name=ANONYMOUS*)
 | eval User=if(mvcount(Account_Name)&amp;gt;1, mvindex(Account_Name,1), mvindex(Account_Name, 0)) 
 | eval User=lower(User)
 | search NOT (User=*$$ OR User=system)
 | lookup dnslookup clientip as Source_Network_Address OUTPUT clienthost
 | transaction User maxevents=2 startswith="EventCode=4624" endswith="EventCode=4634" maxspan=-1
 | eval Logofftime=_time+duration
 | convert timeformat="%m/%d/%y %H:%M:%S" ctime(_time) as Logontime
 | convert timeformat="%m/%d/%y %H:%M:%S" ctime(Logofftime) as Logofftime
 | eval h=floor(duration/3600) | eval m=floor((duration-(h*3600))/60) | eval s=floor(duration-(h*3600)-(m*60)) | eval SessionDuration=h."h ".m."m ".s."s"
 | dedup Logontime, Logofftime, SessionDuration, User, clienthost
 | table Logontime, Logofftime, SessionDuration, User, clienthost
 | sort User ComputerName
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like to put the search "1" inside of the search "2" . I have tried doing this following the tutorials, but it's still not working, ---------------I have used the brackets [] and I was sure that the fields and the index were the same in both searches.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index="br_activedirectory_microsoft"  EventCode=4624 OR EventCode=4634 Account_Name=A* Account_Domain=AGBANESPA
 [ search index="br_activedirectory_microsoft" EventCode=4624 OR EventCode=4634  Account_Domain=AGBANESPA Account_Name=A* 
 | fields Account_Domain, Account_Name, Source_Network_Address
 | dedup Account_Domain, Account_Name, Source_Network_Address
 | lookup dnslookup clientip as Source_Network_Address OUTPUT clienthost
 | eval user = substr(mvindex(Account_Name,1),2,4)
 | eval hostname = substr(clienthost,3,4)
 | where user !=hostname
 | lookup new_hostname_lookup hostname as hostname OUTPUT ENDEREÇO, UF, REG, CEP , REDE
 | lookup new_user_lookup user as user OUTPUT ENDEREÇO_user, UF_user, REG_user, CEP_user ,REDE_user
 | where REG !=REG_user AND REDE !=REDE_user
 | table Account_Name
 | rename Account_Name as "Siglas dos usúarios com acessos indevidos"] 
 | search NOT (Account_Name=$$ OR Account_Name=SYSTEM OR Account_Name=ANONYMOUS*)
 | eval User=if(mvcount(Account_Name)&amp;gt;1, mvindex(Account_Name,1), mvindex(Account_Name, 0)) 
 | eval User=lower(User)
 | search NOT (User=*$$ OR User=system)
 | lookup dnslookup clientip as Source_Network_Address OUTPUT clienthost
 | transaction User maxevents=2 startswith="EventCode=4624" endswith="EventCode=4634" maxspan=-1
 | eval Logofftime=_time+duration
 | convert timeformat="%m/%d/%y %H:%M:%S" ctime(_time) as Logontime
 | convert timeformat="%m/%d/%y %H:%M:%S" ctime(Logofftime) as Logofftime
 | eval h=floor(duration/3600) | eval m=floor((duration-(h*3600))/60) | eval s=floor(duration-(h*3600)-(m*60)) | eval SessionDuration=h."h ".m."m ".s."s"
 | dedup Logontime, Logofftime, SessionDuration, User, clienthost
 | table Logontime, Logofftime, SessionDuration, User, clienthost
 | sort User ComputerName
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Could you guys help making the right search?&lt;/P&gt;

&lt;P&gt;Thanks for all.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jun 2019 13:45:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-subsearch/m-p/444868#M126158</guid>
      <dc:creator>lucasdc</dc:creator>
      <dc:date>2019-06-28T13:45:12Z</dc:date>
    </item>
    <item>
      <title>Re: Help with subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-subsearch/m-p/444869#M126159</link>
      <description>&lt;P&gt;Can you please explain what you want to achieve? And in what sense "it's still not working"? What output do you get, how is that different from what you expected?&lt;/P&gt;

&lt;P&gt;What troubleshooting have you done so far? Have you executed the subsearch (in that exact form) on its own, to confirm that gives the expected result?&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jun 2019 14:15:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-subsearch/m-p/444869#M126159</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2019-06-28T14:15:22Z</dc:date>
    </item>
    <item>
      <title>Re: Help with subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-subsearch/m-p/444870#M126160</link>
      <description>&lt;P&gt;I've added backticks for better readability.&lt;/P&gt;

&lt;P&gt;Skalli&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jun 2019 14:23:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-subsearch/m-p/444870#M126160</guid>
      <dc:creator>skalliger</dc:creator>
      <dc:date>2019-06-28T14:23:17Z</dc:date>
    </item>
    <item>
      <title>Re: Help with subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-subsearch/m-p/444871#M126161</link>
      <description>&lt;P&gt;Your subsearch has this at the end:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rename Account_Name as "Siglas dos usúarios com acessos indevidos"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The final field has to be a field that is in your data. If you remove this line, you will have what you need, as the field passed to the base search will now be a field that actually exists in the index.&lt;/P&gt;</description>
      <pubDate>Sun, 30 Jun 2019 23:58:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-subsearch/m-p/444871#M126161</guid>
      <dc:creator>nvanderwalt_spl</dc:creator>
      <dc:date>2019-06-30T23:58:11Z</dc:date>
    </item>
    <item>
      <title>Re: Help with subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-subsearch/m-p/444872#M126162</link>
      <description>&lt;P&gt;It was the problem! thanks nvanderwalt ,you are the man!&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2019 17:01:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-subsearch/m-p/444872#M126162</guid>
      <dc:creator>lucasdc</dc:creator>
      <dc:date>2019-07-01T17:01:23Z</dc:date>
    </item>
  </channel>
</rss>

