Getting Data In

Splunk train sourcetype doesn't work, gives "Parameters must be in the form '-parameter value'"

jrodman
Splunk Employee
Splunk Employee

When i try to train splunk to automatically recognize files of a given type, I get the following:

# $SPLUNK_HOME/bin/splunk train sourcetype /tmp/maillog qmail_maillog
errror:    Parameters must be in the form '-parameter value'

Am I doing this wrong? Is there a workaround?

Tags (2)
0 Karma
1 Solution

jrodman
Splunk Employee
Splunk Employee

Firstly, for many cases, applying sourcetypes by file pattern can be preferable to content-based recognition. The file pattern rules are easier to audit. This can be done via overlapping input stanzas (in 4.1+), or by source:: regex-like patterns in props.conf.

If you do have the need to apply sourcetypes by content, then the train command is busted (SPL-31078), but it's just a candy wrapper over the following, which you can use directly for full effect:

$SPLUNK_HOME/bin/splunk cmd classify path/to/myfile mysourcetype 


If you're trying to use train to recognize timestamps, I generally recommend using TIME_FORMAT instead.

View solution in original post

jrodman
Splunk Employee
Splunk Employee

Firstly, for many cases, applying sourcetypes by file pattern can be preferable to content-based recognition. The file pattern rules are easier to audit. This can be done via overlapping input stanzas (in 4.1+), or by source:: regex-like patterns in props.conf.

If you do have the need to apply sourcetypes by content, then the train command is busted (SPL-31078), but it's just a candy wrapper over the following, which you can use directly for full effect:

$SPLUNK_HOME/bin/splunk cmd classify path/to/myfile mysourcetype 


If you're trying to use train to recognize timestamps, I generally recommend using TIME_FORMAT instead.

Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

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