Splunk Search

Derive fields from the search params

ericchile
New Member

How can I create a field for different search params and include others as well? Ie

source="/location/to/file" "error" AND ("This is one error" OR "this is another error" OR "this is the last error" | fieldchart count

So that the chart shows the count of each type of error and all the rest are grouped in "other"?

Splunk Novice here so any help would be nice!

Thank you!!

Tags (1)
0 Karma

ericchile
New Member

Sweet. Thank you so much!

0 Karma

chris
Motivator

Hi,

you could try something like this:

 source="/location/to/file" | rex "(?<special_error>This is one error)" | rex "(?<special_error>this is another error)" | eval error_type=if(isnotnull(special_error),special_error,"other") | stats count by error_type

Just a few thoughts on the search

  • it usually makes sense to search for a sourcetype instead of a source
  • rex will extract a field
  • by chaining 2 (or more rexes) for events with a differen format a field with the same name will be created
  • if the error message ist always in the same position of your events a regular expression can be used to catch all the special error messages you want
  • to automate things you can configure the props.conf & transforms.conf to extract fields automatically (step 2)

If you can post some sample events it will be easier to help.

Good luck

Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...