- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So my goal is to be able to pass a file to a splunk-monitored directory.. and have splunk apply it to the appropriate index and sourcetype...by a sort of naming convention.
file would come in as "indexname_sourcetype_filename.txt" or whatever... and my inputs.conf would do the appropriate thing.
is this possible?
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, this should be possible. It would be something along these lines:
In transforms.conf:
[override-sourcetype]
SOURCE_KEY = source
DEST_KEY = MetaData:Sourcetype
REGEX = \w+_(\w+)_\w+\.txt$
FORMAT = sourcetype::$1
[override-index]
SOURCE_KEY = source
DEST_KEY = _MetaData:Index
REGEX = (\w+)_\w+_\w+\.txt$
FORMAT = index::$1
And then in props.conf:
[source::/var/log/inputdir/*]
TRANSFORMS-sourcetype = override-sourcetype
TRANSFORMS-index = override-index
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
I had some trouble defining an indexname out of the path and filename of the sourcefile.
In MetaData:Source, the sourcename is prefixed with 'source::', so you have to consider this in the regex. Further, in the index name, defined in 'FORMAT = ' , there is no prefix. The configuration in the example above has to be 'FORMAT = $1' and not 'FORMAT = index::$1'.
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, this should be possible. It would be something along these lines:
In transforms.conf:
[override-sourcetype]
SOURCE_KEY = source
DEST_KEY = MetaData:Sourcetype
REGEX = \w+_(\w+)_\w+\.txt$
FORMAT = sourcetype::$1
[override-index]
SOURCE_KEY = source
DEST_KEY = _MetaData:Index
REGEX = (\w+)_\w+_\w+\.txt$
FORMAT = index::$1
And then in props.conf:
[source::/var/log/inputdir/*]
TRANSFORMS-sourcetype = override-sourcetype
TRANSFORMS-index = override-index
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
BTW - I was doing this for just the sourcetype override, and needed to change SOURCE_KEY = MetaData:Source
in the transforms.conf [override-sourcetype]
stanza to get this to work.
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ok so no way to create the index dynamically. thanks for this. 🙂
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No, configure inputs.conf as normal, and create each destination index ahead of time via indexes.conf or the Manager. The settings above will override the sourcetype and destination index as the file is indexed. Not sure what happens if the index doesn't exist - it will probably throw an indexing error but it might revert back to the default index.
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
and no inputs.conf at all?
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That is cool. What happens if the index doesnt exist yet?
