<?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 can I break out streamstats into multiple groups? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-break-out-streamstats-into-multiple-groups/m-p/622899#M216556</link>
    <description>&lt;P&gt;I'm wanting to group streamstats results by either one or two fields. Grouping by sourcetype would be sufficient. Grouping by index and sourcetype would be ideal.&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This query works fine for a single sourcetype, however does not work for multiple sourcetypes.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The desired outcome is one record per unique sourcetype and/or index.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Example query:&lt;BR /&gt;&lt;BR /&gt;| tstats count as event_count where index="aws_p" sourcetype="aws:cloudwatch:guardduty" by _time span=1m index sourcetype&lt;BR /&gt;| sort _time&lt;BR /&gt;| streamstats window=1 current=false sum(event_count) as event_count values(_time) as prev_time by index sourcetype&lt;BR /&gt;| eval duration=_time-prev_time&lt;BR /&gt;| eval minutes_between_events=duration/60&lt;BR /&gt;| stats min(minutes_between_events) as min_minutes_between_events avg(minutes_between_events) as avg_minutes_between_events max(minutes_between_events) as max_minutes_between_events by index sourcetype&lt;BR /&gt;| eval avg_minutes_between_events=round(avg_minutes_between_events,0)&lt;BR /&gt;| eval max_hours_between_events=round(max_minutes_between_events/60,2)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;results for multiple sourcetypes&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bandit_0-1669926850213.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/22787i796CD3D4EDDEE02D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="bandit_0-1669926850213.png" alt="bandit_0-1669926850213.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;results for a single sourcetype&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bandit_0-1669926467233.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/22786iCF94AF8954517225/image-size/medium?v=v2&amp;amp;px=400" role="button" title="bandit_0-1669926467233.png" alt="bandit_0-1669926467233.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 01 Dec 2022 20:36:59 GMT</pubDate>
    <dc:creator>bandit</dc:creator>
    <dc:date>2022-12-01T20:36:59Z</dc:date>
    <item>
      <title>How can I break out streamstats into multiple groups?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-break-out-streamstats-into-multiple-groups/m-p/622899#M216556</link>
      <description>&lt;P&gt;I'm wanting to group streamstats results by either one or two fields. Grouping by sourcetype would be sufficient. Grouping by index and sourcetype would be ideal.&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This query works fine for a single sourcetype, however does not work for multiple sourcetypes.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The desired outcome is one record per unique sourcetype and/or index.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Example query:&lt;BR /&gt;&lt;BR /&gt;| tstats count as event_count where index="aws_p" sourcetype="aws:cloudwatch:guardduty" by _time span=1m index sourcetype&lt;BR /&gt;| sort _time&lt;BR /&gt;| streamstats window=1 current=false sum(event_count) as event_count values(_time) as prev_time by index sourcetype&lt;BR /&gt;| eval duration=_time-prev_time&lt;BR /&gt;| eval minutes_between_events=duration/60&lt;BR /&gt;| stats min(minutes_between_events) as min_minutes_between_events avg(minutes_between_events) as avg_minutes_between_events max(minutes_between_events) as max_minutes_between_events by index sourcetype&lt;BR /&gt;| eval avg_minutes_between_events=round(avg_minutes_between_events,0)&lt;BR /&gt;| eval max_hours_between_events=round(max_minutes_between_events/60,2)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;results for multiple sourcetypes&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bandit_0-1669926850213.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/22787i796CD3D4EDDEE02D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="bandit_0-1669926850213.png" alt="bandit_0-1669926850213.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;results for a single sourcetype&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bandit_0-1669926467233.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/22786iCF94AF8954517225/image-size/medium?v=v2&amp;amp;px=400" role="button" title="bandit_0-1669926467233.png" alt="bandit_0-1669926467233.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2022 20:36:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-break-out-streamstats-into-multiple-groups/m-p/622899#M216556</guid>
      <dc:creator>bandit</dc:creator>
      <dc:date>2022-12-01T20:36:59Z</dc:date>
    </item>
    <item>
      <title>Re: How can I break out streamstats into multiple groups?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-break-out-streamstats-into-multiple-groups/m-p/622929#M216560</link>
      <description>&lt;P&gt;When using streamstats + window and a by clause, you need to specify global flag&lt;/P&gt;&lt;P&gt;| streamstats window=1 global=false current=false sum(event_count) as event_count values(_time) as prev_time by index sourcetype&lt;/P&gt;</description>
      <pubDate>Fri, 02 Dec 2022 00:47:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-break-out-streamstats-into-multiple-groups/m-p/622929#M216560</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-12-02T00:47:38Z</dc:date>
    </item>
    <item>
      <title>Re: How can I break out streamstats into multiple groups?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-break-out-streamstats-into-multiple-groups/m-p/623056#M216605</link>
      <description>&lt;P&gt;Thanks for the help &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt; - much appreciated!&lt;/P&gt;</description>
      <pubDate>Fri, 02 Dec 2022 17:49:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-break-out-streamstats-into-multiple-groups/m-p/623056#M216605</guid>
      <dc:creator>bandit</dc:creator>
      <dc:date>2022-12-02T17:49:01Z</dc:date>
    </item>
  </channel>
</rss>

