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
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...