<?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: Joining multiple fields of two searches together on certain conditions in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Joining-multiple-fields-of-two-searches-together-on-certain/m-p/284399#M85994</link>
    <description>&lt;P&gt;Hi Raschko,&lt;/P&gt;

&lt;P&gt;I tried to search for a solution without a left join, but it seems to be not possible without it. &lt;/P&gt;

&lt;P&gt;Thanks for the help!&lt;/P&gt;</description>
    <pubDate>Tue, 02 Aug 2016 14:54:03 GMT</pubDate>
    <dc:creator>horsefez</dc:creator>
    <dc:date>2016-08-02T14:54:03Z</dc:date>
    <item>
      <title>Joining multiple fields of two searches together on certain conditions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Joining-multiple-fields-of-two-searches-together-on-certain/m-p/284397#M85992</link>
      <description>&lt;P&gt;Hi fellow splunkers,&lt;/P&gt;

&lt;P&gt;I currently try to do a splunk auditing by searching which user logged into the system using some sort of useragent and so on. Then I try to check if the user displayed has administration rights by appending the subsearch displayed below. After this I need to somehow check if the user and username of the two searches match. And then somehow write the matching role for it into the event.&lt;BR /&gt;
I'll try to visualize what I want to do, so you hopefully understand it better.&lt;/P&gt;

&lt;P&gt;First my current search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal sourcetype=splunkd_ui_access useragent!="SplunkCli*" user!="-" 
| sort _time
| dedup user clientip useragent
| append [| rest /services/authentication/users splunk_server=* | dedup title roles | fields roles title | rename title as username]
| table _time index user clientip useragent roles username
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The &lt;EM&gt;index=_internal sourcetype=splunkd_ui_access&lt;/EM&gt; events look like the following example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time; index; user; clientip; useragent
2016-07-27 08:56:37.998; _internal; peter; 77.32.89.12; Mozilla Firefox
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The &lt;EM&gt;rest /services/authentication/users splunk_server=&lt;/EM&gt;* events look like the following example&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;roles; username
admin; olaf
admin; peter
user; frank
user; chris
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;When I &lt;EM&gt;| table _time index user clientip useragent roles username&lt;/EM&gt; it looks like that:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time; index; user; clientip; useragent; roles; username
2016-07-27 08:56:37.998; _internal; peter; 77.32.89.12; Mozilla Firefox; ;  
; ; ; ; ; admin; olaf
; ; ; ; ; admin; peter
; ; ; ; ; user; frank
; ; ; ; ; user; chris
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;My goal is to get events like the following example shows by somehow joining/appending the results by matching user==username:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time; index; user; clientip; useragent; roles; username
2016-07-27 08:56:37.998; _internal; peter; 77.32.89.12; Mozilla Firefox;admin; peter 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any ideas how to do that?&lt;/P&gt;

&lt;P&gt;Thanks in advance!&lt;/P&gt;

&lt;P&gt;Best regards, &lt;BR /&gt;
pyro_wood&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:24:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Joining-multiple-fields-of-two-searches-together-on-certain/m-p/284397#M85992</guid>
      <dc:creator>horsefez</dc:creator>
      <dc:date>2020-09-29T10:24:02Z</dc:date>
    </item>
    <item>
      <title>Re: Joining multiple fields of two searches together on certain conditions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Joining-multiple-fields-of-two-searches-together-on-certain/m-p/284398#M85993</link>
      <description>&lt;P&gt;You could use the mentioned "join" command to join both searches together on user. Rename field "title" to the same user field name as in the main search, here field name "user".&lt;/P&gt;

&lt;P&gt;Search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal sourcetype=splunkd_ui_access useragent!="SplunkCli*" user!="-" 
 | sort _time
 | dedup user clientip useragent
 | join type=left user [| rest /services/authentication/users splunk_server=* | dedup title roles | fields roles title | rename title as user]
 | table _time index user clientip useragent roles
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Jul 2016 12:33:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Joining-multiple-fields-of-two-searches-together-on-certain/m-p/284398#M85993</guid>
      <dc:creator>Raschko</dc:creator>
      <dc:date>2016-07-27T12:33:48Z</dc:date>
    </item>
    <item>
      <title>Re: Joining multiple fields of two searches together on certain conditions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Joining-multiple-fields-of-two-searches-together-on-certain/m-p/284399#M85994</link>
      <description>&lt;P&gt;Hi Raschko,&lt;/P&gt;

&lt;P&gt;I tried to search for a solution without a left join, but it seems to be not possible without it. &lt;/P&gt;

&lt;P&gt;Thanks for the help!&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2016 14:54:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Joining-multiple-fields-of-two-searches-together-on-certain/m-p/284399#M85994</guid>
      <dc:creator>horsefez</dc:creator>
      <dc:date>2016-08-02T14:54:03Z</dc:date>
    </item>
    <item>
      <title>Re: Joining multiple fields of two searches together on certain conditions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Joining-multiple-fields-of-two-searches-together-on-certain/m-p/284400#M85995</link>
      <description>&lt;P&gt;Thank you to my past self for asking this question. &lt;BR /&gt;
I was confronted with the same problem today. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Apr 2017 10:46:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Joining-multiple-fields-of-two-searches-together-on-certain/m-p/284400#M85995</guid>
      <dc:creator>horsefez</dc:creator>
      <dc:date>2017-04-28T10:46:16Z</dc:date>
    </item>
  </channel>
</rss>

