<?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: removing duplicate with maximum value in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/removing-duplicate-with-maximum-value/m-p/699287#M237407</link>
    <description>&lt;P&gt;You generally thought well but you have to cast your hostname to lowercase (or uppercase; doesn't matter as long as it's consistent) _before_ you do your stats.&lt;/P&gt;&lt;P&gt;EDIT: I didn't notice it started with tstats. Of course in this case &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt; 's solution is the way to go.&lt;/P&gt;</description>
    <pubDate>Tue, 17 Sep 2024 14:10:22 GMT</pubDate>
    <dc:creator>PickleRick</dc:creator>
    <dc:date>2024-09-17T14:10:22Z</dc:date>
    <item>
      <title>removing duplicate with maximum value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/removing-duplicate-with-maximum-value/m-p/699285#M237405</link>
      <description>&lt;P&gt;Hi All, Can anyone please help me on this ...&lt;/P&gt;
&lt;P&gt;I am framing a SPL query to get list of hosts with their last eventtime.&lt;/P&gt;
&lt;P&gt;SPL query:&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| tstats max(_time) as latest where index=indexname by host  | convert ctime(latest)&lt;/LI-CODE&gt;
&lt;P&gt;From this query, I am getting the list as expected, but with one bug. (If I have a host both in lower case &amp;amp; in upper case, I am getting 2 different entries)&lt;/P&gt;
&lt;P&gt;Eg:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; host&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; latest&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;HOSTNAME1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;09/17/2024 15:27:49&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;hostname1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;08/30/2024 15:27:00&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;hostname2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;09/15/2024 15:27:49&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;HOSTNAME2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;09/13/2024 15:27:49&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;From here, I have to get only one entry for a host along with latest time. (For hostname1, I should get&amp;nbsp;09/17/2024 15:27:49, similarly for hostname2 I should get&amp;nbsp;09/15/2024 15:27:49)&lt;BR /&gt;&lt;BR /&gt;I tried adding the command,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| eval host=upper(host), latest=max(latest) | dedup host&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;But it is not considering max of "latest", and it just showing the single row for each host with random value of "latest"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Can you please suggest me the better way to achieve this. thanks&lt;/P&gt;</description>
      <pubDate>Tue, 17 Sep 2024 14:16:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/removing-duplicate-with-maximum-value/m-p/699285#M237405</guid>
      <dc:creator>RanjiRaje</dc:creator>
      <dc:date>2024-09-17T14:16:19Z</dc:date>
    </item>
    <item>
      <title>Re: removing duplicate with maximum value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/removing-duplicate-with-maximum-value/m-p/699286#M237406</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/254020"&gt;@RanjiRaje&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;please try this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| tstats max(_time) as latest where index=indexname by host  
| eval host=upper(host)
| stats max(latest) AS latest BY host
| convert ctime(latest)&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 17 Sep 2024 13:47:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/removing-duplicate-with-maximum-value/m-p/699286#M237406</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2024-09-17T13:47:12Z</dc:date>
    </item>
    <item>
      <title>Re: removing duplicate with maximum value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/removing-duplicate-with-maximum-value/m-p/699287#M237407</link>
      <description>&lt;P&gt;You generally thought well but you have to cast your hostname to lowercase (or uppercase; doesn't matter as long as it's consistent) _before_ you do your stats.&lt;/P&gt;&lt;P&gt;EDIT: I didn't notice it started with tstats. Of course in this case &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt; 's solution is the way to go.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Sep 2024 14:10:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/removing-duplicate-with-maximum-value/m-p/699287#M237407</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-09-17T14:10:22Z</dc:date>
    </item>
    <item>
      <title>Re: removing duplicate with maximum value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/removing-duplicate-with-maximum-value/m-p/699303#M237410</link>
      <description>&lt;P&gt;thanks sir &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was thinking something complex, but you made it very simple.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Sep 2024 16:02:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/removing-duplicate-with-maximum-value/m-p/699303#M237410</guid>
      <dc:creator>RanjiRaje</dc:creator>
      <dc:date>2024-09-17T16:02:57Z</dc:date>
    </item>
  </channel>
</rss>

