<?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 error stats with multiple codes from each event? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-receiving-error-trend-stats-with-multiple-error-codes/m-p/626824#M217849</link>
    <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp; for the inputs&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 11 Jan 2023 17:12:48 GMT</pubDate>
    <dc:creator>kumar497</dc:creator>
    <dc:date>2023-01-11T17:12:48Z</dc:date>
    <item>
      <title>Why am I receiving error trend stats with multiple error codes from each event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-receiving-error-trend-stats-with-multiple-error-codes/m-p/625802#M217521</link>
      <description>&lt;P&gt;Hi All,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to tabulate the error ratio based on the following scenarios from the unique log event but further using the regex to split the error code causing the total events to be filtered out causing the overall hits to be incorrect while % calculation as the initial no of unique events is not getting preserved with eventstats&amp;nbsp;&lt;/P&gt;
&lt;P&gt;sample log event is in json format as below and multiple errorcodes in same log event which needs a error wise split&lt;/P&gt;
&lt;P class=""&gt;log:&amp;lt;&amp;lt;field1&amp;gt;&amp;gt;,&amp;lt;&amp;lt;field2&amp;gt;&amp;gt;,&amp;lt;&amp;lt;field3&amp;gt;&amp;gt;,error=60KOANEWLH=500.EBS.SYSTEM.100:67MPW4X79FOJ=500.IMS.SERVEROUT.100:3534U6ZIZY39=500.EBS.SERVERIN.100;404.IMS.SERVEROUT.105:3M8TEWEKVIJK=500.IVS.XXXXX.100;404.IMS.XXXX.105:2ILTH9G0UMG1=500.IMS.XXXXXXXX.100:0UAQL48U2KWF=500.EBS.XXXXXXX.100;404.IMS.XXXXXXXXX.105, missingFulfillmentItems,&amp;lt;&amp;lt;field4&amp;gt;&amp;gt;,&amp;lt;&amp;lt;field5&amp;gt;&amp;gt;,&amp;lt;&amp;lt;field6&amp;gt;&amp;gt;&lt;/P&gt;
&lt;P class=""&gt;i would like to get each error code % mainly (500.XX.XXXX.100 count/total hits)&amp;nbsp;&lt;/P&gt;
&lt;P class=""&gt;below is the splunk search filter been used but not getting totalevents, please correct me if there is anything missed,,could someone please assist with an alternate option to compute the error trend..Thanks in advance&lt;/P&gt;
&lt;P class=""&gt;index=&amp;lt;indexname&amp;gt; "Search String" "Type"=prod&amp;nbsp; | eventstats sum(index) as total_hits&lt;BR /&gt;| rex field="log.log" ", error=*(?&amp;lt;errorMap2&amp;gt;.+), missingFulfillmentItems"&lt;BR /&gt;| eval errors0=replace(errorMap2, "=", ";")&lt;BR /&gt;| eval errors1=split(errors0,":")&lt;BR /&gt;| rex field=errors1 "(?&amp;lt;errorCodes&amp;gt;.*)"&lt;BR /&gt;| mvexpand errorCodes&lt;BR /&gt;| eval errorCodes1=split(errorCodes, ";")&lt;BR /&gt;| mvexpand errorCodes1&lt;BR /&gt;| where like(errorCodes1,"%500.IMS.%")&lt;BR /&gt;| stats count by errorCodes1,total_hits&lt;/P&gt;
&lt;P class=""&gt;Note: each log event is unique and has multiple error codes with in the event or no error codes in the event if its success&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jan 2023 16:45:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-receiving-error-trend-stats-with-multiple-error-codes/m-p/625802#M217521</guid>
      <dc:creator>kumar497</dc:creator>
      <dc:date>2023-01-04T16:45:31Z</dc:date>
    </item>
    <item>
      <title>Re: error trend stats with multiple error codes from each event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-receiving-error-trend-stats-with-multiple-error-codes/m-p/625824#M217527</link>
      <description>&lt;P&gt;Shouldn't&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eventstats sum(index) as total_hits&lt;/LI-CODE&gt;&lt;P&gt;be&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eventstats count as total_hits&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 04 Jan 2023 14:47:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-receiving-error-trend-stats-with-multiple-error-codes/m-p/625824#M217527</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-01-04T14:47:45Z</dc:date>
    </item>
    <item>
      <title>Re: error trend stats with multiple error codes from each event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-receiving-error-trend-stats-with-multiple-error-codes/m-p/626214#M217650</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; you are right&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I modified the search as below to compute the error ratio but disk usage is exceeding the configured limits getting the job autofinalized showing 0 events with increased time window but working only with very short duration, Is there a way to optimize further can someone please help&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;index=&amp;lt;indexname&amp;gt; "Search String XXXXXXXXX" "Type"=prod&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;| eventstats count as total_hits&lt;BR /&gt;| rex field="log.log" ", errorMap=*(?&amp;lt;errorMap2&amp;gt;.+),&lt;SPAN&gt;missingFulfillmentItems&lt;/SPAN&gt;"&lt;BR /&gt;| eval errors0=replace(errorMap2, "=", ";")&lt;BR /&gt;| eval errors1=split(errors0,":")&lt;BR /&gt;| rex field=errors1 "(?&amp;lt;errorCodes&amp;gt;.*)"&lt;BR /&gt;| mvexpand errorCodes&lt;BR /&gt;| eval errorCodes1=split(errorCodes, ";")&lt;BR /&gt;| mvexpand errorCodes1&lt;BR /&gt;| where like(errorCodes1,"%500.IMS.%")&lt;BR /&gt;| stats count(errorCodes1) as error_count by errorCodes1,total_hits&lt;BR /&gt;| eval error_ratio=round((error_count/total_hits)*100,2)&lt;BR /&gt;| table errorCodes1,error_count,error_ratio,total_hits&lt;BR /&gt;| sort -error_ratio&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 17:29:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-receiving-error-trend-stats-with-multiple-error-codes/m-p/626214#M217650</guid>
      <dc:creator>kumar497</dc:creator>
      <dc:date>2023-01-06T17:29:47Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I receiving error trend stats with multiple error codes from each event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-receiving-error-trend-stats-with-multiple-error-codes/m-p/626225#M217653</link>
      <description>&lt;P&gt;Phew. That first sentence is lost on me. And lack of capitals and punctuation doesn't help. To be honest, I don't understand what you're trying to do.&lt;/P&gt;&lt;P&gt;And your event is definitely&lt;EM&gt; not&lt;/EM&gt; in json format. Maybe that's one of the json fields, but that's not a json event.&lt;/P&gt;&lt;P&gt;I don't understand the "eventstats sum(index)" part. You're trying to calculate a sum of the string field. That's most probably not what you want. Maybe you simply need "eventstats count"?&lt;/P&gt;&lt;P&gt;BTW, you can probably match your error codes much easier. After getting your errorMap2 just use rex to find all error codes.&lt;/P&gt;&lt;PRE&gt;| rex max_match=0 field=errorMap2 "=(?&amp;lt;errorcode&amp;gt;\d{3}[A-za-z0-9.]+)"&lt;/PRE&gt;&lt;P&gt;Now you can do with those matches whatever you want.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 18:18:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-receiving-error-trend-stats-with-multiple-error-codes/m-p/626225#M217653</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2023-01-06T18:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: error trend stats with multiple error codes from each event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-receiving-error-trend-stats-with-multiple-error-codes/m-p/626226#M217654</link>
      <description>&lt;P&gt;It's most probably because eventstats is a dataset processing command which means that it needs to get all the events from your search before it can process them. That's not good for big searches.&lt;/P&gt;&lt;P&gt;You could try to "cheat" by using streamstats and then chosing max value of your streamstats.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 18:25:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-receiving-error-trend-stats-with-multiple-error-codes/m-p/626226#M217654</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2023-01-06T18:25:29Z</dc:date>
    </item>
    <item>
      <title>Re: error trend stats with multiple error codes from each event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-receiving-error-trend-stats-with-multiple-error-codes/m-p/626230#M217656</link>
      <description>&lt;P&gt;By doing the eventstats count early (before the mvexpands) you are counting the events as total_hits. Your ratio is then comparing each error against the number of events, so, for example, you could have 4 events, one of which has 4 500 errors and the other three have no errors. This would give a ratio of 100%. Is this really what you are intending to do?&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 19:01:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-receiving-error-trend-stats-with-multiple-error-codes/m-p/626230#M217656</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-01-06T19:01:49Z</dc:date>
    </item>
    <item>
      <title>Re: error trend stats with multiple error codes from each event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-receiving-error-trend-stats-with-multiple-error-codes/m-p/626244#M217659</link>
      <description>&lt;P&gt;In fact, the percentages can sum to much more than 100%&lt;/P&gt;&lt;P&gt;Remember that if you're statsing by multivalued fields (or if you count all events early and mvexpand your fields later) the same original event can be counted multiple times.&lt;/P&gt;&lt;P&gt;Percentage counted this way does make sense but one has to understand what sense it is.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 19:50:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-receiving-error-trend-stats-with-multiple-error-codes/m-p/626244#M217659</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2023-01-06T19:50:31Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I receiving error trend stats with multiple error codes from each event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-receiving-error-trend-stats-with-multiple-error-codes/m-p/626313#M217687</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp; for your inputs&amp;nbsp;&lt;/P&gt;&lt;P&gt;yeah total event is in json and the field im trying to extract is part of a "log" attribute in the json event&amp;nbsp;&lt;/P&gt;&lt;P&gt;my intention is to compute each errorcode percentage out of the total no of requests that is logged, In this usecase&amp;nbsp; error codes will be either multiple errors in a single event or no errors, so trying to extract each errorcode and also required to preserve total no of requests as "eventstats count" in the initial phase bcz further error filtering of 5xx(with like function) yields in less num of events hope i made the requirement clear&lt;BR /&gt;&lt;BR /&gt;Thanks i can use the below rex for error extraction which is helpful but still i am unable to compute the error % for a larger duration as the jobs getting finalized exceeding the user quota seems im missing something,&lt;/P&gt;</description>
      <pubDate>Sun, 08 Jan 2023 08:35:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-receiving-error-trend-stats-with-multiple-error-codes/m-p/626313#M217687</guid>
      <dc:creator>kumar497</dc:creator>
      <dc:date>2023-01-08T08:35:53Z</dc:date>
    </item>
    <item>
      <title>Re: error trend stats with multiple error codes from each event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-receiving-error-trend-stats-with-multiple-error-codes/m-p/626314#M217688</link>
      <description>&lt;P&gt;&lt;SPAN&gt;yes right the event counts will not match, my intention is to compute each errorcode percentage out of the total no of requests that is logged, In this usecase&amp;nbsp; error codes will be either multiple errors in a single event or no errors, so trying to extract each errorcode and also required to preserve total no of requests as "eventstats count" in the initial phase bcz further error filtering of 5xx(with like function) yields in less num of events hope i made the requirement clear&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Jan 2023 08:39:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-receiving-error-trend-stats-with-multiple-error-codes/m-p/626314#M217688</guid>
      <dc:creator>kumar497</dc:creator>
      <dc:date>2023-01-08T08:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: error trend stats with multiple error codes from each event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-receiving-error-trend-stats-with-multiple-error-codes/m-p/626319#M217691</link>
      <description>&lt;P&gt;Try something like this to reduce memory requirements as you go&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=&amp;lt;indexname&amp;gt; "Search String XXXXXXXXX" "Type"=prod  
``` Possibly don't need _raw as you appear to have already extracted log.log? ```
| fields - _raw 
``` Count events with streamstats (to keep the pipeline moving) ```
| streamstats count as row 
| rex field="log.log" ", errorMap=*(?&amp;lt;errorMap2&amp;gt;.+),missingFulfillmentItems"
``` Remove fields when you are finished with them ```
| fields - 'log.log'
| eval errors0=replace(errorMap2, "=", ";")
``` Remove fields when you are finished with them ```
| fields - errorMap2
| eval errors1=split(errors0,":")
``` Remove fields when you are finished with them ```
| fields - errors0
| rex field=errors1 "(?&amp;lt;errorCodes&amp;gt;.*)"
``` Remove fields when you are finished with them ```
| fields - errors1
| mvexpand errorCodes
| eval errorCodes1=split(errorCodes, ";")
``` Remove fields when you are finished with them ```
| fields - errorCodes
| mvexpand errorCodes1
``` Use max(row) as your event count ```
| stats count as error_count max(row) as total_hits by errorCodes1
``` Only keep error counts for the codes you are interested in - moved to after stats so that correct max(row) is maintained ```
| where like(errorCodes1,"%500.IMS.%")
| eval error_ratio=round((error_count/total_hits)*100,2)
| table errorCodes1,error_count,error_ratio,total_hits
| sort -error_ratio&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 08 Jan 2023 10:15:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-receiving-error-trend-stats-with-multiple-error-codes/m-p/626319#M217691</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-01-08T10:15:51Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I receiving error trend stats with multiple error codes from each event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-receiving-error-trend-stats-with-multiple-error-codes/m-p/626320#M217692</link>
      <description>&lt;P&gt;Apart from the obvious techniques which &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt; already showed - removing fields to reduce memory footprint, you can do something else. Move the calculations elsewhere &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Drop the eventstats completely. Add a fake fallback value for those events that do not have any errors at all. Then add a fake "count" which will contain value of 1/(number of errors) per event. This way you can do sum(fake_count) by error with your stats. This will give you proper overall count split among different error values. Now you can do eventstats sum on this fake sum which should give you relatively good approximation (might be a tiny bit off due to rounding errors) to the original count.&lt;/P&gt;&lt;P&gt;Edit: Alternatively, you could substitute eventstats with streamstats count which will "number" your events. Then if you get max(count) in your stats, you can easily choose max of those values to be the sequence&amp;nbsp; number of your last event effectively being the count of your events. And don't forget about the fake error to account for events with no error.&lt;/P&gt;</description>
      <pubDate>Sun, 08 Jan 2023 13:38:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-receiving-error-trend-stats-with-multiple-error-codes/m-p/626320#M217692</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2023-01-08T13:38:25Z</dc:date>
    </item>
    <item>
      <title>multiple codes from each event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-receiving-error-trend-stats-with-multiple-error-codes/m-p/626823#M217848</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; this&amp;nbsp; is really helpful but only constraint was around the mvexpand where the memory limits are reaching without sampling, though its working if including sampling ratio&amp;nbsp;&lt;/P&gt;&lt;P&gt;just would like to understand max(row) is the sequence number of each event after splitting the error codes isnt it, will it not generate too many events ,sorry i might be missing something&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;stats count as error_count max(row) as total_hits by errorCodes1&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jan 2023 17:08:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-receiving-error-trend-stats-with-multiple-error-codes/m-p/626823#M217848</guid>
      <dc:creator>kumar497</dc:creator>
      <dc:date>2023-01-11T17:08:40Z</dc:date>
    </item>
    <item>
      <title>error stats with multiple codes from each event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-receiving-error-trend-stats-with-multiple-error-codes/m-p/626824#M217849</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp; for the inputs&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jan 2023 17:12:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-receiving-error-trend-stats-with-multiple-error-codes/m-p/626824#M217849</guid>
      <dc:creator>kumar497</dc:creator>
      <dc:date>2023-01-11T17:12:48Z</dc:date>
    </item>
    <item>
      <title>Re: multiple codes from each event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-receiving-error-trend-stats-with-multiple-error-codes/m-p/626826#M217850</link>
      <description>&lt;P&gt;Actually, it looks like there might be an extra line needed&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;``` Use max(row) as your event count ```
| stats count as error_count max(row) as total_hits by errorCodes1
``` Set total_hits to max before filtering out any events ```
| eventstats max(total_hits) as total_hits
``` Only keep error counts for the codes you are interested in - moved to after stats so that correct max(row) is maintained ```&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Moving the eventstats to here (after the stats by errorCodes1) means it is only processing the stats events rather than all the events.&lt;/P&gt;&lt;P&gt;Also, you should bear in mind the hint from&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;about having a fake error code so that the last row has an error code that appears in errorCodes1 i.e. non-null&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jan 2023 17:26:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-receiving-error-trend-stats-with-multiple-error-codes/m-p/626826#M217850</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-01-11T17:26:04Z</dc:date>
    </item>
  </channel>
</rss>

