Splunk Search

How to create a report on error codes and how many times each occurred over a period of time using regex and timechart?

parameshjava
Explorer

In my application, it will print some error codes like OPT-00A001, OPT-00A002, OPT-00A003, upto OPT-00A010. I need to prepare a report to know each error code and how many times occurred over a period of time.

No idea how to use regex and timechart to get this kind of report. Please suggest.

0 Karma
1 Solution

sundareshr
Legend

Without actual logs, it is very difficult to isolate the pattern for your errorcode to write the correct regex. Having said that, if you error codes are always the same patter "OPT-" followed by 6 characters, then you can use this. This also assumes the error code appears only once an event. This also assumes, this pattern of OPT- followed by 6 chars doesn't occur anywhere else in the event. If it does, this regex will only get the first occurrence

| rex "(?<ec>OPT-\w{6})" | timechart count by ec

View solution in original post

sundareshr
Legend

Without actual logs, it is very difficult to isolate the pattern for your errorcode to write the correct regex. Having said that, if you error codes are always the same patter "OPT-" followed by 6 characters, then you can use this. This also assumes the error code appears only once an event. This also assumes, this pattern of OPT- followed by 6 chars doesn't occur anywhere else in the event. If it does, this regex will only get the first occurrence

| rex "(?<ec>OPT-\w{6})" | timechart count by ec

jmallorquin
Builder

Can you provide some lines of log just to ensure the rex match?

0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...