<?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: How to group by multiple fields? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-group-by-multiple-fields/m-p/628917#M218461</link>
    <description>&lt;P&gt;Avoid join in Splunk where possible - it has limitations and is not really the Splunk way to do things, as joining can easily be done with stats&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;search &amp;lt;dataset_1&amp;gt; OR &amp;lt;dataset_2&amp;gt;
| eval host=if(index=dataset_1, hostname, host)
| stats values(destPort) as ports values(os) as os by host
| stats values(ports) as ports by os&lt;/LI-CODE&gt;&lt;P&gt;Assuming that there is only 1 os per host, then the first stats will give all the ports for the host along with its os and then the second stats will give all the ports by os.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 30 Jan 2023 23:34:00 GMT</pubDate>
    <dc:creator>bowesmana</dc:creator>
    <dc:date>2023-01-30T23:34:00Z</dc:date>
    <item>
      <title>How to group by multiple fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-group-by-multiple-fields/m-p/628858#M218445</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;
&lt;DIV class=""&gt;
&lt;DIV class=""&gt;
&lt;P class=""&gt;I'm kinda new to splunk.&lt;/P&gt;
&lt;P class=""&gt;I have two indizes:&lt;/P&gt;
&lt;OL class=""&gt;
&lt;LI&gt;
&lt;P class=""&gt;Stores events (relevant fields: hostname, destPort)&lt;/P&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;P class=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2. Stores information about infrastructure (relevant fields: host, os)&lt;/P&gt;
&lt;P class=""&gt;I need to show which Ports are used by which os.&lt;/P&gt;
&lt;P class=""&gt;From the first index I need to know which host is using which ports.&lt;/P&gt;
&lt;P class=""&gt;From the second index I want to know which host is using which os. I then want to see, which OS uses which ports. To make it even more difficult, the host is called hostname in index 1 and host in index 2.&lt;/P&gt;
&lt;P class=""&gt;I basically have to group by hostname and then by OS.&lt;/P&gt;
&lt;P class=""&gt;How can i achieve this? What concepts can I use?&lt;/P&gt;
&lt;P class=""&gt;I have two working searches for step 1 and step2, I just dont know how to "join" them together.&lt;/P&gt;
&lt;P class=""&gt;Any help is greatly appreciated, thanks.&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Mon, 30 Jan 2023 16:39:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-group-by-multiple-fields/m-p/628858#M218445</guid>
      <dc:creator>erikschubert</dc:creator>
      <dc:date>2023-01-30T16:39:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to group by multiple fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-group-by-multiple-fields/m-p/628863#M218446</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/253371"&gt;@erikschubert&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;You can try below search:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=events
| fields hostname,destPort
| rename hostname as host
| join type=outer host
    [| search index=infrastructure
     | fields os]
| table host destPort os&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 30 Jan 2023 16:46:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-group-by-multiple-fields/m-p/628863#M218446</guid>
      <dc:creator>tej57</dc:creator>
      <dc:date>2023-01-30T16:46:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to group by multiple fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-group-by-multiple-fields/m-p/628865#M218447</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/155831"&gt;@tej57&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/253371"&gt;@erikschubert&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;You can try below search:&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=events
| fields hostname,destPort
| rename hostname as host
| join type=outer host
    [| search index=infrastructure
     | fields os]
| table host destPort os&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;this displays which host is using which Port, but the column OS stays empty &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2023 17:02:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-group-by-multiple-fields/m-p/628865#M218447</guid>
      <dc:creator>erikschubert</dc:creator>
      <dc:date>2023-01-30T17:02:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to group by multiple fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-group-by-multiple-fields/m-p/628917#M218461</link>
      <description>&lt;P&gt;Avoid join in Splunk where possible - it has limitations and is not really the Splunk way to do things, as joining can easily be done with stats&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;search &amp;lt;dataset_1&amp;gt; OR &amp;lt;dataset_2&amp;gt;
| eval host=if(index=dataset_1, hostname, host)
| stats values(destPort) as ports values(os) as os by host
| stats values(ports) as ports by os&lt;/LI-CODE&gt;&lt;P&gt;Assuming that there is only 1 os per host, then the first stats will give all the ports for the host along with its os and then the second stats will give all the ports by os.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2023 23:34:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-group-by-multiple-fields/m-p/628917#M218461</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-01-30T23:34:00Z</dc:date>
    </item>
  </channel>
</rss>

