Getting Data In

How can I set the sourcetype to a value from the input stream?

ddrillic
Ultra Champion

I have a name value data stream which contains the following - "msg_sourcetype": "syslog-test". How can I set the sourcetype to be - syslog-test?

The following works - | rex "msg_sourcetype\": \"(?<one>[a-zA-Z]*)" ignoring the dash for now.

So, I guess in transforms.conf, I can have something like following, but I'm not sure about the one field...

[<our>_sourcetype]
REGEX = "msg_sourcetype\": \"(?<one>[a-zA-Z]*)" 
FORMAT = sourcetype::$1
DEST_KEY = MetaData:Sourcetype

The following is a big help - Set host values based on event data

Tags (2)
0 Karma
1 Solution

lguinn2
Legend

The following should work. Note that you do not give the field a name in the regular expression. Also, your regular expression did not give the dash as a possible character, so it would not be able to extract syslog-test. Are there any other characters that you should also include?

 [old_sourcetype]
 REGEX = \"msg_sourcetype\": \"([a-zA-Z-]*)\"
 FORMAT = sourcetype::$1
 DEST_KEY = MetaData:Sourcetype

View solution in original post

0 Karma

lguinn2
Legend

The following should work. Note that you do not give the field a name in the regular expression. Also, your regular expression did not give the dash as a possible character, so it would not be able to extract syslog-test. Are there any other characters that you should also include?

 [old_sourcetype]
 REGEX = \"msg_sourcetype\": \"([a-zA-Z-]*)\"
 FORMAT = sourcetype::$1
 DEST_KEY = MetaData:Sourcetype
0 Karma

ddrillic
Ultra Champion

Perfect - thank you!!!

0 Karma
Get Updates on the Splunk Community!

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...