Splunk Search

State with custom source in by clause

rainerst
Engager

Hello,

I am currently faced with the problem while creating stats for a specific event, where the event itself contains a custom source field. With my current search it will use the default source field rather than the custom source field of the event. How can I use this custom source field in the by clause of the stats command?

Here an event sample:

name=testEvent source=application1 eventType=type1

Here the search:

eventType=type1 | stats count as occurrences by source, eventType

Thanks in advance,
Rainer

Tags (1)
0 Karma
1 Solution

lguinn2
Legend

This is a little clunky but it will work

eventType=type1 | rex "source=(?<Source>\S+)"  | stats count as occurrences by Source, eventType

Notice that your custom source is now named "Source". Since field names are case-sensitive, this avoids the conflict.
You could put this regular expression into the appropriate props.conf file and then your "Source" would always be accessible, without the need for the rex command...

View solution in original post

lguinn2
Legend

This is a little clunky but it will work

eventType=type1 | rex "source=(?<Source>\S+)"  | stats count as occurrences by Source, eventType

Notice that your custom source is now named "Source". Since field names are case-sensitive, this avoids the conflict.
You could put this regular expression into the appropriate props.conf file and then your "Source" would always be accessible, without the need for the rex command...

rainerst
Engager

thank you!

0 Karma
Get Updates on the Splunk Community!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...