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!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...