Splunk Search

Grouping by a substring

R0ss
Engager

Hello,

I'm having trouble grouping errors in our Splunk logs. The date and time is appended to the error messages, meaning that every message is unique. For example:

Message=2017-06-19 09:15:23,825 ERROR - Here is the error message that we would like to group on...

I would like to ignore the date/time string and group on the text that appears after this. The best I have come up with is as follows:

Type=Error | eval ErrorString=substr(Message,30,len(Message)) | stats count by ErrorString

But this search still seems to evaluate as if the date is present in the new ErrorString string (the count is always 1 and ErrorString's are duplicated across rows)

Could you help me to write a query that would group the error messages and ignore the date/time.

Thanks,
Ross

0 Karma
1 Solution

dineshraj9
Builder

You can extract the string at the end and use it in the grouping -

<your search> | rex field=Message "(?<ErrorString>ERROR.+)"  | stats count by ErrorString

View solution in original post

dineshraj9
Builder

You can extract the string at the end and use it in the grouping -

<your search> | rex field=Message "(?<ErrorString>ERROR.+)"  | stats count by ErrorString

R0ss
Engager

Perfect, thank you!

0 Karma
Get Updates on the Splunk Community!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...