Splunk Search

How to extract sourcetype using rex?

splunkuseradmin
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

1 Solution

woodcock
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

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