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!

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...