<?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 can I remove a second log entry from a query that seems to be a duplicate. in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/How-can-I-remove-a-second-log-entry-from-a-query-that-seems-to/m-p/416061#M7253</link>
    <description>&lt;P&gt;Thanks!! It turned out to be a mix, I ended up doing this: | sort limit=0 _time | dedup claimID sortby +_time&lt;/P&gt;

&lt;P&gt;The 'sort limit' seems to have arranged the list in the correct order for the 'sortby' to work correctly this time. I honestly don't know why your first answer didn't work, but glad to have gotten this anyway!&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 22:17:26 GMT</pubDate>
    <dc:creator>jkinny</dc:creator>
    <dc:date>2020-09-29T22:17:26Z</dc:date>
    <item>
      <title>How can I remove a second log entry from a query that seems to be a duplicate.</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-can-I-remove-a-second-log-entry-from-a-query-that-seems-to/m-p/416057#M7249</link>
      <description>&lt;P&gt;I am using the transaction function to group several log entries by a 'claimID' field. I've noticed that when I do this, for each 'claimID' I am getting an extra log entry that gets returned 'outside' of the transaction. For all intents and purposes this second entry is a duplicate of the 'endswith' parameter of the transaction. I've tried using the 'dedup' function by the 'claimID' field, but it only seems to throw away the oldest result and keep the newest, as in, it removes the transaction block that I want, but keeps the duplicate. (in the attached screenshot, dedup would keep the top entry and remove the bottom transaction-fied entry)&lt;BR /&gt;
&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/6181i4DA7B5C023441876/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;BR /&gt;
query: index=prd sourcetype=app source="/logs/app.log" ("editCode=CA010" OR "status=A") | transaction claimID endswith="status=A"&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 17:28:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-can-I-remove-a-second-log-entry-from-a-query-that-seems-to/m-p/416057#M7249</guid>
      <dc:creator>jkinny</dc:creator>
      <dc:date>2018-11-30T17:28:37Z</dc:date>
    </item>
    <item>
      <title>Re: How can I remove a second log entry from a query that seems to be a duplicate.</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-can-I-remove-a-second-log-entry-from-a-query-that-seems-to/m-p/416058#M7250</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;you can still use dedup. Just use the sortby clause of dedup. For your example, you could use | dedup claimID sortby +_time&lt;/P&gt;

&lt;P&gt;You can also use sortby -_time if you need it the other way around for other searches.&lt;/P&gt;

&lt;P&gt;Over all, i think you can improve your search in regard to performance by using a clever combination of stats or streamstats and some more splunk spl magic. If needed, you get some more examples here: &lt;A href="https://answers.splunk.com/answers/103/transaction-vs-stats-commands.html"&gt;https://answers.splunk.com/answers/103/transaction-vs-stats-commands.html&lt;/A&gt; and here &lt;A href="https://www.splunk.com/blog/2012/11/29/book-excerpt-when-to-use-transaction-and-when-to-use-stats.html"&gt;https://www.splunk.com/blog/2012/11/29/book-excerpt-when-to-use-transaction-and-when-to-use-stats.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Greetings,&lt;/P&gt;

&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Mon, 03 Dec 2018 10:23:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-can-I-remove-a-second-log-entry-from-a-query-that-seems-to/m-p/416058#M7250</guid>
      <dc:creator>tom_frotscher</dc:creator>
      <dc:date>2018-12-03T10:23:32Z</dc:date>
    </item>
    <item>
      <title>Re: How can I remove a second log entry from a query that seems to be a duplicate.</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-can-I-remove-a-second-log-entry-from-a-query-that-seems-to/m-p/416059#M7251</link>
      <description>&lt;P&gt;Thanks for the response Tom, I'll respond to your second answer first, unless I'm misunderstanding, I think that based on what I'm trying to do, I might need to stick with transaction. I'm basically trying to find instances where status=A exists, but there was no prior log message for the same claimID that shows editCode=CA010. The last section to the query here should turn up any 'orphans' (I don't know what you call an orphan that has a closing entry, but no beginning entry).&lt;/P&gt;

&lt;P&gt;so I tried adding both | dedup claimID sortby +_time and | dedup claimID sortby -_time to the end of my query, and unfortunately both seem to return the same result, and neither is the one that I want. If you look at my screenshot, adding the dedup/sortby command is returning only the top result in my log (@ .716) not the bottom (@.256)&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:16:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-can-I-remove-a-second-log-entry-from-a-query-that-seems-to/m-p/416059#M7251</guid>
      <dc:creator>jkinny</dc:creator>
      <dc:date>2020-09-29T22:16:50Z</dc:date>
    </item>
    <item>
      <title>Re: How can I remove a second log entry from a query that seems to be a duplicate.</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-can-I-remove-a-second-log-entry-from-a-query-that-seems-to/m-p/416060#M7252</link>
      <description>&lt;P&gt;Thats strange,&lt;BR /&gt;
i tried it for myself with a transaction search and it worked like i thought it would work.&lt;/P&gt;

&lt;P&gt;However, you can still do some streamstats and search magic. Append something like this to your search:&lt;/P&gt;

&lt;P&gt;| sort limit=0 _time | streamstats count by group | search count=1 | sort limit=0 -_time&lt;/P&gt;

&lt;P&gt;Does this help?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:15:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-can-I-remove-a-second-log-entry-from-a-query-that-seems-to/m-p/416060#M7252</guid>
      <dc:creator>tom_frotscher</dc:creator>
      <dc:date>2020-09-29T22:15:49Z</dc:date>
    </item>
    <item>
      <title>Re: How can I remove a second log entry from a query that seems to be a duplicate.</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-can-I-remove-a-second-log-entry-from-a-query-that-seems-to/m-p/416061#M7253</link>
      <description>&lt;P&gt;Thanks!! It turned out to be a mix, I ended up doing this: | sort limit=0 _time | dedup claimID sortby +_time&lt;/P&gt;

&lt;P&gt;The 'sort limit' seems to have arranged the list in the correct order for the 'sortby' to work correctly this time. I honestly don't know why your first answer didn't work, but glad to have gotten this anyway!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:17:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-can-I-remove-a-second-log-entry-from-a-query-that-seems-to/m-p/416061#M7253</guid>
      <dc:creator>jkinny</dc:creator>
      <dc:date>2020-09-29T22:17:26Z</dc:date>
    </item>
    <item>
      <title>Re: How can I remove a second log entry from a query that seems to be a duplicate.</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-can-I-remove-a-second-log-entry-from-a-query-that-seems-to/m-p/416062#M7254</link>
      <description>&lt;P&gt;Nice!&lt;/P&gt;

&lt;P&gt;be aware, sort is quite performance heavy. Therefore, it is limited to 10,000 events by default, which in this case we exceeded with the help of the limit=0 option.&lt;/P&gt;

&lt;P&gt;But if your search is still fast enough for your use case, you now have a solution &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2018 16:43:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-can-I-remove-a-second-log-entry-from-a-query-that-seems-to/m-p/416062#M7254</guid>
      <dc:creator>tom_frotscher</dc:creator>
      <dc:date>2018-12-04T16:43:13Z</dc:date>
    </item>
  </channel>
</rss>

