<?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: Result Varies by Including Sort Option in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-latest-status-of-the-workflow/m-p/622804#M216533</link>
    <description>&lt;P&gt;Whereas this behavior is confusing, I still do not understand the reason for this sort.&lt;/P&gt;&lt;P&gt;This said, here is an easy confirmation of the mysterious behavior that everyone can run:&lt;/P&gt;&lt;PRE&gt;index=_internal earliest=-1d@d latest=-0d@d
``` | sort - _time ```
| stats count by eventtype&lt;/PRE&gt;&lt;P&gt;No sort, my search gives&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;eventtype&lt;/TD&gt;&lt;TD&gt;count&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;splunk-access&lt;/TD&gt;&lt;TD&gt;5046&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;splunk-log&lt;/TD&gt;&lt;TD&gt;59418&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;PRE&gt;index=_internal earliest=-1d@d latest=-0d@d
| sort - _time
| stats count by eventtype&lt;/PRE&gt;&lt;P&gt;With count, my count becomes&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;eventtype&lt;/TD&gt;&lt;TD&gt;count&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;splunk-access&lt;/TD&gt;&lt;TD&gt;236&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;splunk-log&lt;/TD&gt;&lt;TD&gt;2722&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;To eliminate variability, this search is limited to the previous day.&lt;/P&gt;&lt;P&gt;I am sure there's an explanation. I just don't have it.&lt;/P&gt;</description>
    <pubDate>Thu, 01 Dec 2022 12:42:45 GMT</pubDate>
    <dc:creator>yuanliu</dc:creator>
    <dc:date>2022-12-01T12:42:45Z</dc:date>
    <item>
      <title>How to get the latest status of the workflow?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-latest-status-of-the-workflow/m-p/622766#M216506</link>
      <description>&lt;P&gt;Hello Splunkers,&lt;/P&gt;
&lt;P&gt;Workflows are monitored through splunk. Workflows has different stages like running , paused, cancelled and completed. I have to get the latest status of the workflow. I am using sort - _time option to get the latest data of the status. Along with the search query by using the sort - _time option, data count varies.&lt;/P&gt;
&lt;P&gt;For last 7 days&lt;/P&gt;
&lt;P&gt;index=... | table _time EXECUTION_NAME STATUS EXECUTION_ID Stage Environment source | dedup EXECUTION_ID | chart count(EXECUTION_ID) as Workflows_Triggered by Environment,STATUS&lt;/P&gt;
&lt;P&gt;Environment COMPLETED PAUSED RUNNING&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;XXX&lt;/TD&gt;
&lt;TD&gt;&lt;STRONG&gt;94498&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;56&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;sort -_time option is used for last 7 days.&lt;/P&gt;
&lt;P&gt;index=... | table _time EXECUTION_NAME STATUS EXECUTION_ID Stage Environment source | &lt;STRONG&gt;sort -_time&lt;/STRONG&gt; | dedup EXECUTION_ID | chart count(EXECUTION_ID) as Workflows_Triggered by Environment,STATUS&lt;/P&gt;
&lt;P&gt;Environment COMPLETED RUNNING&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;XXX&lt;/TD&gt;
&lt;TD&gt;&lt;STRONG&gt;9735&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD&gt;5&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;reason for using sort -_time is get the latest status of the execution_id. completed will be appeared when the dedup is done.&lt;/P&gt;
&lt;P&gt;_time STATUS EXECUTION_ID&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;2022-11-30 12:20:00.492&lt;/TD&gt;
&lt;TD&gt;RUNNING&lt;/TD&gt;
&lt;TD&gt;12345678901&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2022-11-30 12:20:18.000&lt;/TD&gt;
&lt;TD&gt;COMPLETED&lt;/TD&gt;
&lt;TD&gt;12345678911&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;Requesting for support. Thank you !!!&lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2022 16:43:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-latest-status-of-the-workflow/m-p/622766#M216506</guid>
      <dc:creator>Nithianandan</dc:creator>
      <dc:date>2022-12-01T16:43:41Z</dc:date>
    </item>
    <item>
      <title>Re: Result Varies by Including Sort Option</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-latest-status-of-the-workflow/m-p/622804#M216533</link>
      <description>&lt;P&gt;Whereas this behavior is confusing, I still do not understand the reason for this sort.&lt;/P&gt;&lt;P&gt;This said, here is an easy confirmation of the mysterious behavior that everyone can run:&lt;/P&gt;&lt;PRE&gt;index=_internal earliest=-1d@d latest=-0d@d
``` | sort - _time ```
| stats count by eventtype&lt;/PRE&gt;&lt;P&gt;No sort, my search gives&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;eventtype&lt;/TD&gt;&lt;TD&gt;count&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;splunk-access&lt;/TD&gt;&lt;TD&gt;5046&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;splunk-log&lt;/TD&gt;&lt;TD&gt;59418&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;PRE&gt;index=_internal earliest=-1d@d latest=-0d@d
| sort - _time
| stats count by eventtype&lt;/PRE&gt;&lt;P&gt;With count, my count becomes&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;eventtype&lt;/TD&gt;&lt;TD&gt;count&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;splunk-access&lt;/TD&gt;&lt;TD&gt;236&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;splunk-log&lt;/TD&gt;&lt;TD&gt;2722&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;To eliminate variability, this search is limited to the previous day.&lt;/P&gt;&lt;P&gt;I am sure there's an explanation. I just don't have it.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2022 12:42:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-latest-status-of-the-workflow/m-p/622804#M216533</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-12-01T12:42:45Z</dc:date>
    </item>
    <item>
      <title>Re: Result Varies by Including Sort Option</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-latest-status-of-the-workflow/m-p/622806#M216535</link>
      <description>&lt;P&gt;Firstly, small technical remark - if you post a search, include it as a code block or a preformatted paragraph - it's easier to read.&lt;/P&gt;&lt;P&gt;But to the point.&lt;/P&gt;&lt;P&gt;There are some things that shouldn't be happening here &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt;index=... &lt;BR /&gt;| table _time EXECUTION_NAME STATUS EXECUTION_ID Stage Environment source&lt;BR /&gt;| dedup EXECUTION_ID&lt;BR /&gt;| chart count(EXECUTION_ID) as Workflows_Triggered by Environment,STATUS&lt;/PRE&gt;&lt;P&gt;1. Don't table too early. Table is a transforming command which means that it will move the processing pipeline to search-heads. It's nice to have it at the end of your search for presentation of the results but in the middle of your search you most probably get better results with fields command which is a distributable streamming commands. (if you want to get rid of _raw, just do "| fields - _raw").&lt;/P&gt;&lt;P&gt;2. Your thinking is wrong here. You do a dedup EXECUTION_ID which means that you'll get only the first encountered event with given EXECUTION_ID regardless of other fields. If your events always contain the same Environment and STATUS fields, it could be OK, but otherwise out of every possible combination of Environment and STATUS values you'll only count your EXECUTION_ID into on of those groups. That's most probably not what you meant.&lt;/P&gt;&lt;P&gt;You only get your EXECUTION_ID counted for a single _first encountered_ (which does not have to be the earliest! typically search results are given in reverse chronological order) combination of Environment STATUS (and other fields as well). So if you resort your data, you might pick another event from deduping.&lt;/P&gt;&lt;P&gt;A run-anywhere example to show what I mean&lt;/P&gt;&lt;PRE&gt;| makeresults count=60&lt;BR /&gt;| streamstats count&lt;BR /&gt;| eval _time=_time-count &lt;BR /&gt;| eval field1=count % 5&lt;BR /&gt;| eval field2=count % 4&lt;BR /&gt;| eval field3=count % 3&lt;BR /&gt;| fields - count&lt;BR /&gt;| sort - _time&lt;BR /&gt;| dedup field1&lt;/PRE&gt;&lt;P&gt;If you cut the search before the dedup, you'll see that you have every possible combination of (0-4), (0-3) and (0-2) ranges. But if you dedup it on one of the fields you'll only get some combinations in results.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2022 13:17:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-latest-status-of-the-workflow/m-p/622806#M216535</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-12-01T13:17:13Z</dc:date>
    </item>
  </channel>
</rss>

