<?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: Get fields from two searches with two common fields in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Get-fields-from-two-searches-with-two-common-fields/m-p/404249#M171934</link>
    <description>&lt;P&gt;Not sure about the host field, but in theory... well, try:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index=unix type="ANOM_LOGIN_FAILURES" OR type="USER_LOGIN" OR type="LOGIN") OR (index="os" sourcetype="Unix:UserAccounts") | eval id=coalesce(auid, user_id) | stats count as Attemps, count(eval(type="ANOM_LOGIN_FAILURES")) as Failed, count(eval(type="USER_LOGIN" OR type="LOGIN")) as Success values(user) as user by host, id | where Failed&amp;gt;0 AND Success&amp;gt;0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And don't start using join! &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 10 Apr 2019 13:56:31 GMT</pubDate>
    <dc:creator>knielsen</dc:creator>
    <dc:date>2019-04-10T13:56:31Z</dc:date>
    <item>
      <title>Get fields from two searches with two common fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Get-fields-from-two-searches-with-two-common-fields/m-p/404247#M171932</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I'm getting a trouble with this situation. I have two searches:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;From the first one i get host and auid:&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;index=unix | fields host type auid hostname &lt;BR /&gt;
| eval mainhost=host &lt;BR /&gt;
| search type="ANOM_LOGIN_FAILURES" OR type="USER_LOGIN" OR type="LOGIN" &lt;BR /&gt;
| stats count as Attemps, count(eval(type="ANOM_LOGIN_FAILURES")) as Failed, count(eval(type="USER_LOGIN" OR type="LOGIN")) as Success by auid mainhost &lt;BR /&gt;
| where Failed&amp;gt;0 AND Success&amp;gt;0 &lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;And i want to use these two fields on subsearch to get the username linked to that auid:&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;| appendcols maxtime=3600 &lt;BR /&gt;
    [ search index="os" host=$mainhost$ sourcetype="Unix:UserAccounts" user_id=$auid$ &lt;BR /&gt;
    | table user &lt;BR /&gt;
    | dedup user]&lt;BR /&gt;
| table auid,mainhost,Attemps,Failed,Success,user&lt;/P&gt;

&lt;P&gt;but it doesn't work. I'm not getting any information on user field but if i change the $mainhost$ and $auid$ with the value returned by the main search, it works propertly. How can i use main fields on subsearch to filter its results?&lt;/P&gt;

&lt;P&gt;Thank you for your time.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:04:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Get-fields-from-two-searches-with-two-common-fields/m-p/404247#M171932</guid>
      <dc:creator>srteclesmayer</dc:creator>
      <dc:date>2020-09-30T00:04:21Z</dc:date>
    </item>
    <item>
      <title>Re: Get fields from two searches with two common fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Get-fields-from-two-searches-with-two-common-fields/m-p/404248#M171933</link>
      <description>&lt;P&gt;hi @srteclesmayer &lt;/P&gt;

&lt;P&gt;Instead of appendcols try with &lt;CODE&gt;|join id&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Apr 2019 13:35:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Get-fields-from-two-searches-with-two-common-fields/m-p/404248#M171933</guid>
      <dc:creator>harishalipaka</dc:creator>
      <dc:date>2019-04-10T13:35:38Z</dc:date>
    </item>
    <item>
      <title>Re: Get fields from two searches with two common fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Get-fields-from-two-searches-with-two-common-fields/m-p/404249#M171934</link>
      <description>&lt;P&gt;Not sure about the host field, but in theory... well, try:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index=unix type="ANOM_LOGIN_FAILURES" OR type="USER_LOGIN" OR type="LOGIN") OR (index="os" sourcetype="Unix:UserAccounts") | eval id=coalesce(auid, user_id) | stats count as Attemps, count(eval(type="ANOM_LOGIN_FAILURES")) as Failed, count(eval(type="USER_LOGIN" OR type="LOGIN")) as Success values(user) as user by host, id | where Failed&amp;gt;0 AND Success&amp;gt;0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And don't start using join! &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Apr 2019 13:56:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Get-fields-from-two-searches-with-two-common-fields/m-p/404249#M171934</guid>
      <dc:creator>knielsen</dc:creator>
      <dc:date>2019-04-10T13:56:31Z</dc:date>
    </item>
  </channel>
</rss>

