<?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: Give result of different field if first field matches in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Give-result-of-different-field-if-first-field-matches/m-p/143774#M39975</link>
    <description>&lt;P&gt;Try the updated answer. I believe index=main doesn't have srcIP but the equivalent field is Source_Network_Address. Updated query reflects that.&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 17:04:57 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2020-09-28T17:04:57Z</dc:date>
    <item>
      <title>Give result of different field if first field matches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Give-result-of-different-field-if-first-field-matches/m-p/143771#M39972</link>
      <description>&lt;P&gt;I have a search that I want to do. If the search comes back true, then I want to take the srcIP and search in a different index. That search needs to match on that index and then provide me with a username. I have the following, but I can't get past the second search:&lt;/P&gt;

&lt;P&gt;index=dnsserver | lookup malwaredomains domain | search isbad=true | table srcIP,domain | join srcIP [ search index=main ]&lt;/P&gt;

&lt;P&gt;What I'm doing is searching index=dnsserver and then doing the lookup. The table is created with srcIP and domain as column headers. Then I want to join the main index. The main index has two fields: Source_Network_Address and User_Name. I figured I could get my result from the first set, join on srcIP from the first to Source_Network_Address to find a match. When that match is found, I want to only give the User_Name value in a table aligned with the first table. I'm stuck at this point.&lt;/P&gt;

&lt;P&gt;I have 1.1.1.1 in the first search, and 1.1.1.1 and bob in the second. I want a table to look like:&lt;/P&gt;

&lt;P&gt;srcIP              domain          User_Name&lt;BR /&gt;
1.1.1.1            test.com           bob&lt;/P&gt;

&lt;P&gt;Thank you for any help you can give!&lt;BR /&gt;
John&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:04:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Give-result-of-different-field-if-first-field-matches/m-p/143771#M39972</guid>
      <dc:creator>johnblakley</dc:creator>
      <dc:date>2020-09-28T17:04:41Z</dc:date>
    </item>
    <item>
      <title>Re: Give result of different field if first field matches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Give-result-of-different-field-if-first-field-matches/m-p/143772#M39973</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=dnsserver OR index=main | stats values(domain) as domain values(User_Name) as User_Name by srcIP | lookup malwaredomains domain | search isbad=true | table srcIP domain User_Name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR&lt;BR /&gt;
&lt;STRONG&gt;Updated&lt;/STRONG&gt; &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=dnsserver | lookup malwaredomains domain | search isbad=true | table srcIP,domain | join srcIP type=left [search index=main | stats count by Source_Network_Address User_Name | fields - count | rename Source_Network_Address as srcIP] | table srcIP domain User_Name 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Updated2&lt;/STRONG&gt; for faster execution&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=dnsserver | lookup malwaredomains domain | search isbad=true | stats count by srcIP,domain | fields - count | join srcIP type=left [search index=main [search index=dnsserver | lookup malwaredomains domain | search isbad=true | stats count by srcIP | table srcIP | rename srcIP as Source_Network_Address]| stats count by Source_Network_Address User_Name | fields - count | rename Source_Network_Address as srcIP] | table srcIP domain User_Name 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Jul 2014 18:09:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Give-result-of-different-field-if-first-field-matches/m-p/143772#M39973</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-07-15T18:09:10Z</dc:date>
    </item>
    <item>
      <title>Re: Give result of different field if first field matches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Give-result-of-different-field-if-first-field-matches/m-p/143773#M39974</link>
      <description>&lt;P&gt;Neither of these gave the result I'm needing unfortunately. The first search takes way too long to run in that I had to stop it. The second one gave the result that I received with an earlier query where it gave the srcIP and domain, but the User_Name is empty.&lt;/P&gt;

&lt;P&gt;Thank you for the response!&lt;BR /&gt;
John&lt;/P&gt;</description>
      <pubDate>Tue, 15 Jul 2014 20:30:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Give-result-of-different-field-if-first-field-matches/m-p/143773#M39974</guid>
      <dc:creator>johnblakley</dc:creator>
      <dc:date>2014-07-15T20:30:00Z</dc:date>
    </item>
    <item>
      <title>Re: Give result of different field if first field matches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Give-result-of-different-field-if-first-field-matches/m-p/143774#M39975</link>
      <description>&lt;P&gt;Try the updated answer. I believe index=main doesn't have srcIP but the equivalent field is Source_Network_Address. Updated query reflects that.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:04:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Give-result-of-different-field-if-first-field-matches/m-p/143774#M39975</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2020-09-28T17:04:57Z</dc:date>
    </item>
    <item>
      <title>Re: Give result of different field if first field matches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Give-result-of-different-field-if-first-field-matches/m-p/143775#M39976</link>
      <description>&lt;P&gt;It still didn't show a username under the User_Name column unfortunately. I get the IP that matches on the first search along with the domain. The User_Name is in the second search, but it's not a field being searched on. I need that field based off of the match from the IP address in the first search and cross reference that to the second search. Once the association is done, I need to show the username from the User_Name field.&lt;/P&gt;

&lt;P&gt;Thank you for all of your help again! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:05:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Give-result-of-different-field-if-first-field-matches/m-p/143775#M39976</guid>
      <dc:creator>johnblakley</dc:creator>
      <dc:date>2020-09-28T17:05:06Z</dc:date>
    </item>
    <item>
      <title>Re: Give result of different field if first field matches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Give-result-of-different-field-if-first-field-matches/m-p/143776#M39977</link>
      <description>&lt;P&gt;Is below query shows list of all srcIP and corresponding User_Name values from index main??&lt;/P&gt;

&lt;P&gt;index=main | stats count by Source_Network_Address User_Name | fields - count | rename Source_Network_Address as srcIP&lt;/P&gt;

&lt;P&gt;From the first query we get srcIP, domain and we then try to associate them based on srcIP to the 2nd search/subsearch. This should work if there are matching data between both the searches. Would it be possible for you to provide some sample data from both the indexes?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:05:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Give-result-of-different-field-if-first-field-matches/m-p/143776#M39977</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2020-09-28T17:05:22Z</dc:date>
    </item>
    <item>
      <title>Re: Give result of different field if first field matches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Give-result-of-different-field-if-first-field-matches/m-p/143777#M39978</link>
      <description>&lt;P&gt;Sure.. below is the "index=dnsserver | lookup malwaredomains domain | search isbad=true" query:&lt;/P&gt;

&lt;P&gt;7/15/14 &lt;BR /&gt;
12:11:08.000 PM &lt;BR /&gt;
7/15/2014 12:11:08 PM 0F10 PACKET  0000000002863AE0 UDP Rcv x.x.x.x  12f6   Q [0001   D   NOERROR] A      .storage.stgbssint.com.&lt;BR /&gt;
domain = storage.stgbssint.com host = myServer source = c:\Windows\system32\dns\dns.log sourcetype = dns srcIP = x.x.x.x&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jul 2014 15:11:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Give-result-of-different-field-if-first-field-matches/m-p/143777#M39978</guid>
      <dc:creator>johnblakley</dc:creator>
      <dc:date>2014-07-16T15:11:02Z</dc:date>
    </item>
    <item>
      <title>Re: Give result of different field if first field matches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Give-result-of-different-field-if-first-field-matches/m-p/143778#M39979</link>
      <description>&lt;P&gt;Here is the "index=main Source_Network_Address=x.x.x.x" query:&lt;/P&gt;

&lt;P&gt;7/15/14 &lt;BR /&gt;
11:07:21.000 AM &lt;BR /&gt;
20140715110721.000000&lt;BR /&gt;
Category=2&lt;BR /&gt;
CategoryString=Logon/Logoff&lt;BR /&gt;
EventCode=540&lt;BR /&gt;
EventIdentifier=540&lt;BR /&gt;
Show all 46 lines&lt;BR /&gt;
ComputerName = myComputerName Source_Network_Address = x.x.x.x (matches above in lookup query) User_Name = Bob-Smith$ host = myComputerName source = WMI:WinEventLog:Security sourcetype = WMI:WinEventLog:Security&lt;/P&gt;

&lt;P&gt;The first query has the srcIP field that I need to tie into the second queries Source_Network_Address field.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:05:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Give-result-of-different-field-if-first-field-matches/m-p/143778#M39979</guid>
      <dc:creator>johnblakley</dc:creator>
      <dc:date>2020-09-28T17:05:25Z</dc:date>
    </item>
    <item>
      <title>Re: Give result of different field if first field matches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Give-result-of-different-field-if-first-field-matches/m-p/143779#M39980</link>
      <description>&lt;P&gt;I then need to print out the User_Name field if the Source_Network_Address and srcIP match.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:05:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Give-result-of-different-field-if-first-field-matches/m-p/143779#M39980</guid>
      <dc:creator>johnblakley</dc:creator>
      <dc:date>2020-09-28T17:05:28Z</dc:date>
    </item>
    <item>
      <title>Re: Give result of different field if first field matches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Give-result-of-different-field-if-first-field-matches/m-p/143780#M39981</link>
      <description>&lt;P&gt;Well, That's what the updated search does. &lt;BR /&gt;
1) Gets the list of srcIP and domain (after filter based on lookup)&lt;/P&gt;

&lt;P&gt;index=dnsserver | lookup malwaredomains domain | search isbad=true | table srcIP,domain&lt;/P&gt;

&lt;P&gt;2) Gets the list of srcIP(Source_Network_Address renamed) and User_Name &lt;/P&gt;

&lt;P&gt;index=main | stats count by Source_Network_Address User_Name | fields - count | rename Source_Network_Address as srcIP&lt;/P&gt;

&lt;P&gt;3) correlates the data using join based on srcIP&lt;/P&gt;

&lt;P&gt;| join type=left srcIP &lt;/P&gt;

&lt;P&gt;The User_Name field will be empty if there are no matching srcIP between two search results.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:05:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Give-result-of-different-field-if-first-field-matches/m-p/143780#M39981</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2020-09-28T17:05:33Z</dc:date>
    </item>
    <item>
      <title>Re: Give result of different field if first field matches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Give-result-of-different-field-if-first-field-matches/m-p/143781#M39982</link>
      <description>&lt;P&gt;Are all the fields srcIP, Source_Network_Address and User_Name all extracted? (shown on the field list if you do "index=main" or "index=dnsserver")&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:05:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Give-result-of-different-field-if-first-field-matches/m-p/143781#M39982</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2020-09-28T17:05:36Z</dc:date>
    </item>
    <item>
      <title>Re: Give result of different field if first field matches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Give-result-of-different-field-if-first-field-matches/m-p/143782#M39983</link>
      <description>&lt;P&gt;Yes they're extracted: (Italicized)&lt;/P&gt;

&lt;P&gt;domain = storage.stgbssint.com host = myServer source = c:Windowssystem32dnsdns.log sourcetype = dns &lt;EM&gt;srcIP&lt;/EM&gt; = x.x.x.x&lt;/P&gt;

&lt;P&gt;ComputerName = myComputerName &lt;EM&gt;Source_Network_Address&lt;/EM&gt; = x.x.x.x (matches above in lookup query) &lt;EM&gt;User_Name&lt;/EM&gt; = Bob-Smith$ host = myComputerName source = WMI:WinEventLog:Security sourcetype = WMI:WinEventLog:Security&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:05:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Give-result-of-different-field-if-first-field-matches/m-p/143782#M39983</guid>
      <dc:creator>johnblakley</dc:creator>
      <dc:date>2020-09-28T17:05:41Z</dc:date>
    </item>
    <item>
      <title>Re: Give result of different field if first field matches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Give-result-of-different-field-if-first-field-matches/m-p/143783#M39984</link>
      <description>&lt;P&gt;Okay...I let your query run...it takes forever, but it did work this time. I'm not 100% certain why it didn't work earlier, so I'm wondering if I'm searching a good field. I'll mark your original answer as correct though. I have some learning to do &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Thank you for all of your help!&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jul 2014 15:36:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Give-result-of-different-field-if-first-field-matches/m-p/143783#M39984</guid>
      <dc:creator>johnblakley</dc:creator>
      <dc:date>2014-07-16T15:36:55Z</dc:date>
    </item>
  </channel>
</rss>

