Splunk Search
Highlighted

How to extract sourcetype using rex?

Path Finder

Hi everyone,

I have 40 source type with different names so I was wondering if i can extract sourcetype using rex.

abcd2-vooo-abcd05.org.example.com

thanks

Highlighted

Re: How to extract sourcetype using rex?

Esteemed Legend

You are doing it wrong and you are thinking about fixing it wrong. You are bringing these in with the NIX TA and you have not configured it correctly (optimally) so Splunk is guessing at what to use for values for sourcetype. Don't feel bad; there is no documentation on exactly how to do this so we will document it here. The main problem is that you have enabled one of the monitor stanzas but did not set sourcetypes (the default settings do not either). The "normal" way to do this is to put sourcetype=foo underneath the monitor stanza, but in the case of this TA, there are so many different types of files that match each monitor stanza, that the only way to do this would be to break each monitor stanza into many others. Most people take this route, but this is somewhat untidy. What I like to do instead, is put lines like this into props.conf and deploy them in the local directory of the TA to the Forwarders (NOT the Indexers):

[source::...maillog]
sourcetype = maillog
SHOULD_LINEMERGE = false
EVENT_BREAKER_ENABLE = true

[source::...httpd_access.log*]
sourcetype = httpd_access
SHOULD_LINEMERGE = false
EVENT_BREAKER_ENABLE = true

[source::...syslog*]
sourcetype = syslog
SHOULD_LINEMERGE = false
EVENT_BREAKER_ENABLE = true

[source::...cron]
sourcetype = cron
SHOULD_LINEMERGE = false
EVENT_BREAKER_ENABLE = true

[source::...rhsm.log]
sourcetype = rhsm

[source::...rhsmcertd.log]
sourcetype = rhsmcertd
#SHOULD_LINEMERGE = false
#EVENT_BREAKER_ENABLE = true

View solution in original post

0 Karma