Splunk Enterprise

Set transform base on sourcetype

MichalC
Engager
Hi, I'm using the Journald input in univarsal forwarder to collect logs form journald: https://docs.splunk.com/Documentation/Splunk/9.3.2/Data/CollecteventsfromJournalD. When the data comes, I set the sourcetype dynamically based on the value of the journald TRANSPORT field. This works fine.
After that, I would like to apply other transforms to the logs with a certain sourcetypes e.g. remove the logs if the log has a certain phrase. Unfortunately, for some reason, the second transform is not working. Here is the props and configs that I'm using
 
here is my transforms.conf:
 
[set_new_sourcetype]
SOURCE_KEY = field:TRANSPORT
REGEX = ([^\s]+)
FORMAT = sourcetype::$1
DEST_KEY = MetaData:Sourcetype
 
[setnull_syslog_test]
REGEX = (?i)test
DEST_KEY = queue
FORMAT = nullQueue
 
here is my pros.conf:
 
[source::journald:///var/log/journal]
TRANSFORMS-change_sourcetype = set_new_sourcetype
 
[sourcetype::syslog]
TRANSFORMS-setnull = setnull_syslog_test
 
Any idea why the setnull_syslog_test transform is not working?
Labels (2)
0 Karma
1 Solution

PickleRick
SplunkTrust
SplunkTrust

Two things.

1. Stanzas are (unless explicitly set for source or host) based on sourcetype. Don't put "sourcetype::" in stanza specification.

2. If your idea was to cast sourcetype from A to B and then use transforms defined for sourcetype B then it won't work. The list of operations which will be performed on an event is decided at the beginning of the ingestion pipeline. The only way to change it "midflight" is to use the CLONE_SOURCETYPE transform but it's more complicated than simple sourcetype rewrite.

View solution in original post

0 Karma

PickleRick
SplunkTrust
SplunkTrust

Two things.

1. Stanzas are (unless explicitly set for source or host) based on sourcetype. Don't put "sourcetype::" in stanza specification.

2. If your idea was to cast sourcetype from A to B and then use transforms defined for sourcetype B then it won't work. The list of operations which will be performed on an event is decided at the beginning of the ingestion pipeline. The only way to change it "midflight" is to use the CLONE_SOURCETYPE transform but it's more complicated than simple sourcetype rewrite.

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!

Index This | What travels the world but is also stuck in place?

April 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...