Splunk Search

Grouping Errors extracted with field extraction for to run trasform commands

VI371887
Path Finder

Hi All,

I am trying to group different errors that i have extracted to run transform commands, like stats, chart, etc.

i have extracted errors like xyzerror, abcerror, deferror, jklerror.

Now I want to be able to group them under ErrorStrings field and to be able to run something like ...

Query : index=xyz | stats count by ErrorString

So i can get count of each error string or other possible options..

I have tried them with saving whole query in eventtype =ErrorString but it doesn't help, also lookup doesn't seems to help bcuz lack of key value structure of it..

Tags (1)
0 Karma

soumyasaha25
Contributor

Hi, your requirement seems quite similar to one that i had last year.
My solution then was to save the list of error strings in a lookup file, then run the below query on it

index = abc sourcetype="xyz"
| rename _raw as rawText
| eval match_string=[|inputlookup search_string.csv |stats values(search_string) as query | eval query=mvjoin(query,",") | fields query | format "" "" "" "" "" ""]
| eval match_string=split(match_string,",")
| mvexpand match_string
| where like(rawText,"%"+match_string+"%")
| stats values(host) AS HostName count by match_string

mind you its a very heavy search query, but works fine with small data volumes. here the lookup file is saved as search_string.csv which has only one column named as "search_string".

Do let me know if this works for you. if so dont forget to hit the accept button.

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 ...