<?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 count number of events and length along with the median value ? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-events-and-length-along-with-the-median/m-p/618342#M214906</link>
    <description>&lt;P&gt;In that case, it seems finding the median and the events that are far away from the median could be a good way to identify which sourcetypes need attention to look at for 'log volume reduction analysis'.&lt;BR /&gt;&lt;BR /&gt;This is the SPL, I am using,&lt;BR /&gt;any suggestion to improve it to look at the culprit&amp;nbsp; sourcetypes?&lt;BR /&gt;&lt;BR /&gt;index=* sourcetype=*&lt;BR /&gt;| eval eventSize=len(_raw)&lt;BR /&gt;| table eventSize sourcetype index _raw&lt;BR /&gt;| sort - eventSize&lt;BR /&gt;| stats median(eventSize) as median_eventSize, avg(eventSize) as avg_eventSize , count(_raw) as numberOfEvents by index, sourcetype&lt;BR /&gt;| sort median_eventSize | head 10&lt;/P&gt;</description>
    <pubDate>Wed, 26 Oct 2022 09:28:42 GMT</pubDate>
    <dc:creator>zacksoft_wf</dc:creator>
    <dc:date>2022-10-26T09:28:42Z</dc:date>
    <item>
      <title>How to count number of events and length along with the median value ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-events-and-length-along-with-the-median/m-p/618327#M214896</link>
      <description>&lt;P&gt;I want to be able to able to count the number of events and the median length of events per sourcetype in Splunk ?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I'm trying to figure out the average/median size of evets for each sourcetype.&lt;BR /&gt;By size, I mean the charachter length of the raw events.&amp;nbsp; and then multiply the count of events with the median size to get an idea of what sourcetypes contain big events , so that I can use the data for event size reduction if that is possible.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2022 08:14:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-events-and-length-along-with-the-median/m-p/618327#M214896</guid>
      <dc:creator>zacksoft_wf</dc:creator>
      <dc:date>2022-10-26T08:14:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to count number of events and length along with the median value ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-events-and-length-along-with-the-median/m-p/618328#M214897</link>
      <description>&lt;P&gt;On the surface, this is all it takes&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats count median(length) by sourcetype&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;provided the field length contains the length of each event. &amp;nbsp;But I'm nearly certain that some information is missing.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2022 08:13:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-events-and-length-along-with-the-median/m-p/618328#M214897</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-10-26T08:13:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to count number of events and length along with the median value ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-events-and-length-along-with-the-median/m-p/618332#M214899</link>
      <description>&lt;P&gt;index=* sourcetype=*&lt;BR /&gt;| eval length = len(_raw)&lt;BR /&gt;| stats count median(length) as median_length by index, sourcetype&lt;BR /&gt;| sort median_length&lt;BR /&gt;&lt;BR /&gt;I tried something like this.&lt;BR /&gt;Can I count the number of events per sourcetype ? the "| stats count" doesn't give me the right result.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2022 08:39:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-events-and-length-along-with-the-median/m-p/618332#M214899</guid>
      <dc:creator>zacksoft_wf</dc:creator>
      <dc:date>2022-10-26T08:39:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to count number of events and length along with the median value ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-events-and-length-along-with-the-median/m-p/618333#M214900</link>
      <description>&lt;P&gt;&lt;FONT face="andale mono,times"&gt;| stats count by sourcetype&lt;/FONT&gt; gives you number of events by sourcetype. &amp;nbsp;If you ask for&amp;nbsp;&lt;FONT face="andale mono,times"&gt;| stats count by index, sourcetype&lt;/FONT&gt;&amp;nbsp;as your illustrated code shows, it will give you number of events by index by sourcetype. &amp;nbsp;Which one do you want?&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2022 08:44:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-events-and-length-along-with-the-median/m-p/618333#M214900</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-10-26T08:44:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to count number of events and length along with the median value ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-events-and-length-along-with-the-median/m-p/618334#M214901</link>
      <description>&lt;LI-CODE lang="markup"&gt;| eval length=length(_raw)
| stats count median(length) as median by sourcetype&lt;/LI-CODE&gt;&lt;P&gt;Having said that, why not sum the lengths&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval length=length(_raw)
| stats count sum(length) as total by sourcetype&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 26 Oct 2022 08:57:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-events-and-length-along-with-the-median/m-p/618334#M214901</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-10-26T08:57:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to count number of events and length along with the median value ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-events-and-length-along-with-the-median/m-p/618335#M214902</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp; for the suggestion.&lt;BR /&gt;What I am trying to figure out is, the median length of events for a sourcetype , to see which sourcetypes have abnormally long events, and if they unnecessary can we trim it.&lt;BR /&gt;Hence I wanted a SPL that would give me the median lenght of events and count of events per sourcetype and possibly another field that will multiply median * event_count&amp;nbsp; to tell me which sourectyped I need to look at for log volume/event size reduction analysis.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2022 09:05:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-events-and-length-along-with-the-median/m-p/618335#M214902</guid>
      <dc:creator>zacksoft_wf</dc:creator>
      <dc:date>2022-10-26T09:05:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to count number of events and length along with the median value ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-events-and-length-along-with-the-median/m-p/618338#M214904</link>
      <description>&lt;P&gt;The median may not necessarily be useful.&lt;/P&gt;&lt;P&gt;For example, if you had ten events with lengths of 5, 10, 10, 10, 10, 10, 10, 10, 25, 100, your median would be 10, so median * count =100, but if you add them up you get 200. The mean however is 20, so mean * count = 200.&lt;/P&gt;&lt;P&gt;However, if you were interested in deviations from the "norm" to find which source types have outliers, median would be better as 25 is 2.5 times the median and 100 is 10 times the median, and only 1.25 and 5 times the mean.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2022 09:14:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-events-and-length-along-with-the-median/m-p/618338#M214904</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-10-26T09:14:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to count number of events and length along with the median value ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-events-and-length-along-with-the-median/m-p/618342#M214906</link>
      <description>&lt;P&gt;In that case, it seems finding the median and the events that are far away from the median could be a good way to identify which sourcetypes need attention to look at for 'log volume reduction analysis'.&lt;BR /&gt;&lt;BR /&gt;This is the SPL, I am using,&lt;BR /&gt;any suggestion to improve it to look at the culprit&amp;nbsp; sourcetypes?&lt;BR /&gt;&lt;BR /&gt;index=* sourcetype=*&lt;BR /&gt;| eval eventSize=len(_raw)&lt;BR /&gt;| table eventSize sourcetype index _raw&lt;BR /&gt;| sort - eventSize&lt;BR /&gt;| stats median(eventSize) as median_eventSize, avg(eventSize) as avg_eventSize , count(_raw) as numberOfEvents by index, sourcetype&lt;BR /&gt;| sort median_eventSize | head 10&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2022 09:28:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-events-and-length-along-with-the-median/m-p/618342#M214906</guid>
      <dc:creator>zacksoft_wf</dc:creator>
      <dc:date>2022-10-26T09:28:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to count number of events and length along with the median value ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-events-and-length-along-with-the-median/m-p/618351#M214909</link>
      <description>&lt;P&gt;I might approach it like this:&lt;/P&gt;&lt;P&gt;Find the median size by index and source type&lt;/P&gt;&lt;P&gt;Determine deviation of each event as a multiple of the median&lt;/P&gt;&lt;P&gt;Count the number of events and the number of events where the deviation is twice the median (you could use 3 times or something else depending on how diverse your normal data is)&lt;/P&gt;&lt;P&gt;Determine the percentage of outlier events your source type have.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=* sourcetype=*
| eval eventSize=len(_raw)
| eventstats median(eventSize) as median_eventSize by index, sourcetype
| eval deviation = eventSize / median_eventSize
| stats count count(eval(deviation&amp;gt;2)) as count_doubleMedian by index, sourcetype
| eval percentage_outliers = 100*count_doubleMedian/count
| sort 0 -percentage_outliers&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 26 Oct 2022 10:25:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-events-and-length-along-with-the-median/m-p/618351#M214909</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-10-26T10:25:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to count number of events and length along with the median value ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-events-and-length-along-with-the-median/m-p/618377#M214919</link>
      <description>&lt;P&gt;Thank you so much&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2022 12:34:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-events-and-length-along-with-the-median/m-p/618377#M214919</guid>
      <dc:creator>zacksoft_wf</dc:creator>
      <dc:date>2022-10-26T12:34:07Z</dc:date>
    </item>
  </channel>
</rss>

