Getting Data In

Is it possible to generate the sourcetype based on the source?

ddrillic
Ultra Champion

We have hundreds of ldap servers ready to be splunked. We would like to generate the sourcetype based on the source. Here is a small sample of the layout -

alt text
Is it possible to create the sourcetype based on the source?

Tags (1)
1 Solution

jkat54
SplunkTrust
SplunkTrust

Here’s how you do it

inputs.conf

[monitor:///path/to/ldaplogsABC/*.log]
sourcetype=yourSourcetype
crcSalt=<SOURCE>

props.conf

[yourSourcetype]
TRANSFORMS-src2st=src2st

transforms.conf

[src2st]
SOURCE_KEY = MetaData:Source
REGEX = -(\w+)(-\w+)?\/(\w+)
FORMAT = MetaData:Sourcetype
DEST_KEY = sourcetype::ldap:$1:prd:$3

Reload data.

Sorry so many updates... takes me a long time to get these answers right.

View solution in original post

jkat54
SplunkTrust
SplunkTrust

Here’s how you do it

inputs.conf

[monitor:///path/to/ldaplogsABC/*.log]
sourcetype=yourSourcetype
crcSalt=<SOURCE>

props.conf

[yourSourcetype]
TRANSFORMS-src2st=src2st

transforms.conf

[src2st]
SOURCE_KEY = MetaData:Source
REGEX = -(\w+)(-\w+)?\/(\w+)
FORMAT = MetaData:Sourcetype
DEST_KEY = sourcetype::ldap:$1:prd:$3

Reload data.

Sorry so many updates... takes me a long time to get these answers right.

ddrillic
Ultra Champion

Not sure about it ...

Are these two upside down?

FORMAT = MetaData:Sourcetype
DEST_KEY = sourcetype::ldap:$1:prd:$3

Should it be?

FORMAT =  sourcetype::ldap:$1:prd:$3
DEST_KEY = MetaData:Sourcetype  
0 Karma

ddrillic
Ultra Champion

Gorgeous solution @jkat54.

0 Karma

adonio
Ultra Champion

not sure you can do dynamic inputs.conf, maybe i am wrong, and in that case i would love to learn how to do so.
in anycase, it seems like any log path will have their own sourcetype, so, create a quick script that writes your inputs.conf and youll be fine

0 Karma

ddrillic
Ultra Champion

@adonio,

-- create a quick script that writes your inputs.conf and you'll be fine

What does it mean?

0 Karma

adonio
Ultra Champion

ddrillic
Ultra Champion

Much appreciated @adonio.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...