<?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 display cumulative results' count of events in timechart by hour? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-cumulative-results-count-of-events-in-timechart/m-p/247143#M73713</link>
    <description>&lt;P&gt;What was the error you get? Try the updated query.&lt;/P&gt;</description>
    <pubDate>Mon, 28 Nov 2016 14:27:39 GMT</pubDate>
    <dc:creator>sundareshr</dc:creator>
    <dc:date>2016-11-28T14:27:39Z</dc:date>
    <item>
      <title>How to display cumulative results' count of events in timechart by hour?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-cumulative-results-count-of-events-in-timechart/m-p/247140#M73710</link>
      <description>&lt;P&gt;I want to show the sum of events in a search from the earliest time to the time increasing hour by hour. Because I want to see the sum of events changing with the time passing. How can i make it?&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Features&lt;/STRONG&gt;&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;calculate sum of events rom the earliest time to the time increasing hour by hour. For example: the query earliest time is -24 hours, and i need to know the sum of events in [-24,-23] hours, [-24,-22] hours and [-24,-21] hours...&lt;/LI&gt;
&lt;LI&gt;There is a subsearch in the query.&lt;/LI&gt;
&lt;LI&gt;The query for events is that the events are created but not started. And the events will be created or started at any time. So i need to calculate the sum from earliest time to a specified time, and make it a chart to see the change.&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Now my code is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="index_kkk" category=Created earliest=-1d
| search NOT [search index="index_kkk" AND category=Started earliest=-1d 
                     | eval id=taskRequestId 
                     | fields id
             ]
| timechart count span=1h 
| streamstats sum(count) as cumulative
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Anyone can help me?&lt;/P&gt;</description>
      <pubDate>Fri, 25 Nov 2016 10:23:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-cumulative-results-count-of-events-in-timechart/m-p/247140#M73710</guid>
      <dc:creator>wencheng199999</dc:creator>
      <dc:date>2016-11-25T10:23:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to display cumulative results' count of events in timechart by hour?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-cumulative-results-count-of-events-in-timechart/m-p/247141#M73711</link>
      <description>&lt;P&gt;Do you not get the desired results with your query? You should probably consider not using a sub-search for performance reasons. Like this&lt;/P&gt;

&lt;P&gt;*&lt;STRONG&gt;&lt;EM&gt;UPDATED&lt;/EM&gt;&lt;/STRONG&gt;*&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index="index_xxx" (category=Created OR category="Started")  earliest=-1d
 | eval taskRequestId=coalesce(taskRequestId, id)
 | eventstats dc(category) as nbr_categories by taskRequestId 
 | where nbr_categories=1
 | timechart span=1h count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 Nov 2016 13:56:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-cumulative-results-count-of-events-in-timechart/m-p/247141#M73711</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-11-25T13:56:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to display cumulative results' count of events in timechart by hour?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-cumulative-results-count-of-events-in-timechart/m-p/247142#M73712</link>
      <description>&lt;P&gt;&lt;EM&gt;@sundareshr Thanks. I've tried your query in splunk, but there is a error. There are some background features of this problem i need to tell you. So if you got it, i would appreaciated that you give me some advices to solve this problem!&lt;/EM&gt;&lt;/P&gt;

&lt;HR /&gt;

&lt;H2&gt;Features&lt;/H2&gt;

&lt;UL&gt;
&lt;LI&gt; A task has two category but shares only one taskId. And the task in splunk index has two events by different category that is either category=Created or category=Started.&lt;/LI&gt;
&lt;LI&gt; A task is created first and then started. Not every task is started just after created.&lt;/LI&gt;
&lt;LI&gt; So i need to i need to know the sum of tasks created but not started in [-24,-23], [-24,-22] and [-24,-21] ... [-24,now] hour. &lt;/LI&gt;
&lt;LI&gt; After i draw the chart, i can know the change trends of how many tasks created but not started.&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;My query can just show the sum of tasks created but not started in [-24,now]hour. That troubled me.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;
index="index_kkk" category=Created earliest=-1d&lt;BR /&gt;
| search NOT [search index="index_kkk" AND category=Started earliest=-1d &lt;BR /&gt;
                     | fields taskId &lt;BR /&gt;
             ]&lt;BR /&gt;
| timechart count span=1h&lt;BR /&gt;
| streamstats sum(count) as cumulative&lt;BR /&gt;
&lt;/CODE&gt;&lt;BR /&gt;
Is that clear for you? Could you give me some advices? Thank you very much!&lt;/P&gt;&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Mon, 28 Nov 2016 09:04:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-cumulative-results-count-of-events-in-timechart/m-p/247142#M73712</guid>
      <dc:creator>wencheng199999</dc:creator>
      <dc:date>2016-11-28T09:04:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to display cumulative results' count of events in timechart by hour?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-cumulative-results-count-of-events-in-timechart/m-p/247143#M73713</link>
      <description>&lt;P&gt;What was the error you get? Try the updated query.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2016 14:27:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-cumulative-results-count-of-events-in-timechart/m-p/247143#M73713</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-11-28T14:27:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to display cumulative results' count of events in timechart by hour?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-cumulative-results-count-of-events-in-timechart/m-p/247144#M73714</link>
      <description>&lt;P&gt;*@sundareshr Thanks. I've tried your query in splunk, the query get the created tasks number for each hour. But it didn't judge whether the task is started. The dc(category) is that you put to make it? but index="acadci_wk_prod" category=taskCreated make dc(category) always "1". So the query get the created tasks number for each hour.&lt;/P&gt;

&lt;P&gt;I try to delete the "category=taskCreated", but i find that there is another trouble made by my own. The taskId named different at two events that it call "id" in created tasks,but "taskRequestId" in started tasks. Is that ok not changing the log script in the machine but still complete what i need? Thanks!&lt;BR /&gt;
*&lt;/P&gt;

&lt;HR /&gt;

&lt;H2&gt;what i do:&lt;/H2&gt;

&lt;UL&gt;
&lt;LI&gt;&lt;P&gt;```&lt;BR /&gt;
index="index_xxx" category=Created earliest=-1d&lt;BR /&gt;
| eval taskRequestId=id&lt;BR /&gt;
| eventstats dc(category) as nbr_categories by taskRequestId &lt;BR /&gt;
| where nbr_categories=1&lt;BR /&gt;
| timechart span=1h count&lt;/P&gt;

&lt;P&gt;```&lt;BR /&gt;
It work in my splunk search, get the created tasks number for each hour. &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/140181"&gt;@sundareshr&lt;/a&gt; Thank you very much!&lt;/P&gt;&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:56:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-cumulative-results-count-of-events-in-timechart/m-p/247144#M73714</guid>
      <dc:creator>wencheng199999</dc:creator>
      <dc:date>2020-09-29T11:56:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to display cumulative results' count of events in timechart by hour?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-cumulative-results-count-of-events-in-timechart/m-p/247145#M73715</link>
      <description>&lt;P&gt;Since the ids are different (id vs taskRequestId), you will need to coalesce in to a single fieldname. Try the updated query. The &lt;CODE&gt;dc(category)&lt;/CODE&gt; will updated each event with &lt;CODE&gt;disctinct_count(category) by taskRequestId&lt;/CODE&gt;, we then exclude events where &lt;CODE&gt;dc(Category)&amp;gt;1&lt;/CODE&gt; which means, &lt;CODE&gt;taskRequestId&lt;/CODE&gt; has more than one category (created, started)&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2016 03:38:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-cumulative-results-count-of-events-in-timechart/m-p/247145#M73715</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-11-29T03:38:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to display cumulative results' count of events in timechart by hour?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-cumulative-results-count-of-events-in-timechart/m-p/247146#M73716</link>
      <description>&lt;P&gt;*@sundareshr Thanks. I've tried your query in splunk, the query get the results like before.&lt;BR /&gt;
*&lt;/P&gt;

&lt;HR /&gt;

&lt;H2&gt;my query now:&lt;/H2&gt;

&lt;UL&gt;
&lt;LI&gt;&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;
index="index_xxx" (category=Created OR category="Started")  earliest=-1d&lt;BR /&gt;
| eval taskRequestId=coalesce(taskRequestId, id)&lt;BR /&gt;
| eventstats dc(category) as nbr_categories by taskRequestId&lt;BR /&gt;
| where nbr_categories=1&lt;BR /&gt;
| timechart span=1h count&lt;BR /&gt;
&lt;/CODE&gt;&lt;BR /&gt;
It works in my splunk search, gets the created tasks number in time range [-1d,now]. But not [-24,-23] hours, [-24,-22] hours and [-24,-21]...chart. Can the "timechart span=1h count" be changed to make what i need?  @sundareshr Thank you very much!&lt;/P&gt;&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Tue, 29 Nov 2016 05:59:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-cumulative-results-count-of-events-in-timechart/m-p/247146#M73716</guid>
      <dc:creator>wencheng199999</dc:creator>
      <dc:date>2016-11-29T05:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to display cumulative results' count of events in timechart by hour?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-cumulative-results-count-of-events-in-timechart/m-p/247147#M73717</link>
      <description>&lt;P&gt;*@sundareshr Sorry. I think the "timechart span=1h count" only counts the task created and not started in a time range of [-k,-k+1]hour. so,it was not from -24houes. but a time span of a hour. Do you agree?&lt;BR /&gt;
*&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2016 08:01:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-cumulative-results-count-of-events-in-timechart/m-p/247147#M73717</guid>
      <dc:creator>wencheng199999</dc:creator>
      <dc:date>2016-11-29T08:01:48Z</dc:date>
    </item>
  </channel>
</rss>

