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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...