<?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 How to get the top 1 data per host? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-get-the-top-1-data-per-host/m-p/412349#M72993</link>
    <description>&lt;P&gt;I have a log where the mount usage of every host gets logged. So there can be multiple mounts per host. The data can be following - &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Host | Mount_Name | Usage
________________________________
host1 | /tmp | 90
host1 | /opt | 92
host2 | /opt | 81
host2 | /tmp | 90
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So the result would be -&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Host | Mount_Name | Usage
________________________________
host1 | /opt | 92
host2 | /tmp | 90
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Which means for every host I need the highest mount usage.&lt;/P&gt;</description>
    <pubDate>Thu, 28 Jun 2018 13:34:27 GMT</pubDate>
    <dc:creator>anirban_nag</dc:creator>
    <dc:date>2018-06-28T13:34:27Z</dc:date>
    <item>
      <title>How to get the top 1 data per host?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-get-the-top-1-data-per-host/m-p/412349#M72993</link>
      <description>&lt;P&gt;I have a log where the mount usage of every host gets logged. So there can be multiple mounts per host. The data can be following - &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Host | Mount_Name | Usage
________________________________
host1 | /tmp | 90
host1 | /opt | 92
host2 | /opt | 81
host2 | /tmp | 90
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So the result would be -&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Host | Mount_Name | Usage
________________________________
host1 | /opt | 92
host2 | /tmp | 90
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Which means for every host I need the highest mount usage.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jun 2018 13:34:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-get-the-top-1-data-per-host/m-p/412349#M72993</guid>
      <dc:creator>anirban_nag</dc:creator>
      <dc:date>2018-06-28T13:34:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the top 1 data per host?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-get-the-top-1-data-per-host/m-p/412350#M72994</link>
      <description>&lt;P&gt;add this end of your query -- &lt;CODE&gt;|sort -Usage |dedup Host&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jun 2018 13:49:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-get-the-top-1-data-per-host/m-p/412350#M72994</guid>
      <dc:creator>harishalipaka</dc:creator>
      <dc:date>2018-06-28T13:49:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the top 1 data per host?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-get-the-top-1-data-per-host/m-p/412351#M72995</link>
      <description>&lt;P&gt;Hi @anirban_nag,,&lt;/P&gt;

&lt;P&gt;Try,&lt;/P&gt;

&lt;P&gt;if you need mount point also part of the result&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="your index" sourcetype="your sourcetype" | eventstats max(Usage) as max_usage by Host|where Usage=max_usage
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If mount point is not needed,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    index="your index" sourcetype="your sourcetype" | stats max(Usage) by Host
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Jun 2018 13:53:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-get-the-top-1-data-per-host/m-p/412351#M72995</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2018-06-28T13:53:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the top 1 data per host?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-get-the-top-1-data-per-host/m-p/412352#M72996</link>
      <description>&lt;P&gt;@harishalipaka your comment is most apt for the question. Please submit an answer and I will accept.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jun 2018 15:28:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-get-the-top-1-data-per-host/m-p/412352#M72996</guid>
      <dc:creator>anirban_nag</dc:creator>
      <dc:date>2018-06-29T15:28:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the top 1 data per host?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-get-the-top-1-data-per-host/m-p/412353#M72997</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="Host | Mount_Name | Usage
________________________________
host1 | /tmp | 90
host1 | /opt | 92
host2 | /opt | 81
host2 | /tmp | 90" 

| rename COMMENT AS "Everything above generates sample event data; everything below is your solution"

| rex max_match=0 "[\r\n](?&amp;lt;raw&amp;gt;[^\r\n]+\d+)" 
| mvexpand raw
| rex max_match=0 field=raw "^(?&amp;lt;Host&amp;gt;\S+)\s+\|\s+(?&amp;lt;Mount_Name&amp;gt;\/\S+)\s+\|\s+(?&amp;lt;Usage&amp;gt;\d+)$"
| dedup Host Mount_Name
| fields Host Mount_Name Usage
| fields - _*
| eventstats max(Usage) AS max_usage BY Mount_Name
| where Usage==max_usage
| fields - max_usage
| dedup Mount_Name
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Jul 2018 04:06:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-get-the-top-1-data-per-host/m-p/412353#M72997</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2018-07-16T04:06:11Z</dc:date>
    </item>
  </channel>
</rss>

