Splunk Search

Changing sourcetype with regex

ddarmand
Communicator

I try this in transforms.conf :

[Hirschmann]
DEST_KEY = MetaData:Sourcetype
REGEX =  "\S[A-Z]+\s[0-9]+\s[0-9]+:[0-9]+:[0-9]+\s[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+-.\s[A-Z0-9_]+\[[0-9]+\]:\s[a-z0-9_/.]+\([0-9]+\)\s[0-9]+\s%%\s.+"
FORMAT = sourcetype::Hirschmann

(the regex is working when i use * | regex "\S[A-Z]+\s[0-9]+\s[0-9]+:[0-9]+:[0-9]+\s[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+-.\s[A-Z0-9_]+\[[0-9]+\]:\s[a-z0-9_/.]+\([0-9]+\)\s[0-9]+\s%%\s.+"
in search bar)

but it's still marked "syslog" on sourcetype

Can you help me ?

0 Karma
1 Solution

dart
Splunk Employee
Splunk Employee

You'll need a corresponding props.conf entry, do you have one? It should look roughly like this:

## props.conf
[syslog]
TRANSFORM-force-sourcetype-hirschmann = Hirshmann

Additionally you shouldn't quote your REGEX:

## transforms.conf
[Hirschmann]
DEST_KEY = MetaData:Sourcetype
REGEX =  \S[A-Z]+\s[0-9]+\s[0-9]+:[0-9]+:[0-9]+\s[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+-.\s[A-Z0-9_]+\[[0=9]+\]:\s[a-z0-9_/.]+\([0-9]+\)\s[0-9]+\s%%\s.+
FORMAT = sourcetype::Hirschmann

View solution in original post

dart
Splunk Employee
Splunk Employee

You'll need a corresponding props.conf entry, do you have one? It should look roughly like this:

## props.conf
[syslog]
TRANSFORM-force-sourcetype-hirschmann = Hirshmann

Additionally you shouldn't quote your REGEX:

## transforms.conf
[Hirschmann]
DEST_KEY = MetaData:Sourcetype
REGEX =  \S[A-Z]+\s[0-9]+\s[0-9]+:[0-9]+:[0-9]+\s[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+-.\s[A-Z0-9_]+\[[0=9]+\]:\s[a-z0-9_/.]+\([0-9]+\)\s[0-9]+\s%%\s.+
FORMAT = sourcetype::Hirschmann

kristian_kolb
Ultra Champion

Hi, this config setting should go on the first splunk instance that performs parsing. Normally this is either a Heavy Forwarder or an Indexer. See more here;

http://wiki.splunk.com/Where_do_I_configure_my_Splunk_settings

If you're still not getting any data transformed to the Hirschmann sourcetype, you should probably look closer at the regex. It seems a bit complicated, and there might be easier ways of writing it.

/K

0 Karma

ddarmand
Communicator

it's not working, i have multiple index, does this count ? also i have forwarders and i am on my main splunk, maybe i need to add this on the right forwarder ?

0 Karma
Get Updates on the Splunk Community!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...