Getting Data In

How to set Source equal to filename in input.conf?

moaf13
Path Finder

There are a lot of documentation on how to set Host equal to filename or directory name, however i couldn't find anything on how to set source equal to file name?

[monitor://.......\fil.log]
disabled=0
source=???
sourcetype= logFile

props.conf

[logFile]
setting
.
.
.

Tags (1)
0 Karma
1 Solution

somesoni2
Revered Legend

Try this as the REGEX in your transforms.conf

[replacedefaultsource]
SOURCE_KEY = MetaData:Source
REGEX = E:\\Users\\([^\\]+)\\fil.txt
DEST_KEY = MetaData:Source
FORMAT= source::$1

View solution in original post

somesoni2
Revered Legend

Try this as the REGEX in your transforms.conf

[replacedefaultsource]
SOURCE_KEY = MetaData:Source
REGEX = E:\\Users\\([^\\]+)\\fil.txt
DEST_KEY = MetaData:Source
FORMAT= source::$1

moaf13
Path Finder

Thank you very much. That's exactly what i was looking for.

I also added another change which was removing [source::E:\Users\Documents\fil.txt] entirly from props.conf and moving TRANSFORMS-replace_source to sourcetype setting for anyone looking at this answer in the future.

[WindowsFile]
bunch of setting.....
TRANSFORMS-replace_source = replacedefaultsource

removed ([source::E:\Users\Documents\fil.txt]
TRANSFORMS-replace_source = replacedefaultsource)

Do you know why I had to do that? does splunk prioritize sourcetype setting than other settings in props.conf?

0 Karma

sundareshr
Legend

The source of an event is the name of the file, stream, or other input from which the event originates. For data monitored from files and directories, the value of source is the full path, such as /archive/server1/var/log/messages.0 or /var/log/. The value of source for network-based data sources is the protocol and port, such as UDP:514

http://docs.splunk.com/Documentation/Splunk/6.5.0/Data/Aboutdefaultfields

0 Karma

moaf13
Path Finder

Thank you for answering, but this is what I have

[monitor://E:\Users\Documents\fil.txt]
disabled=0
Sourcetype = WindowsFile
queue = parsingQueue

props.conf

[WindowsFile]
bunch of setting.....

[source::E:\Users\Documents\fil.txt]
TRANSFORMS-replace_source = replacedefaultsource

Tranforms.conf

[replacedefaultsource]
SOURCE_KEY = MetaData:Source
REGEX = E:\Users\(Documents)\fil.txt
DEST_KEY = MetaData:Source
FORMAT= source::$1

That's the setting that i have and it's not working, I don't want to full path, I just want the filename. this is what i have and it's not working?

0 Karma
Get Updates on the Splunk Community!

Splunk Mobile: Your Brand-New Home Screen

Meet Your New Mobile Hub  Hello Splunk Community!  Staying connected to your data—no matter where you are—is ...

Introducing Value Insights (Beta): Understand the Business Impact your organization ...

Real progress on your strategic priorities starts with knowing the business outcomes your teams are delivering ...

Enterprise Security (ES) Essentials 8.3 is Now GA — Smarter Detections, Faster ...

As of today, Enterprise Security (ES) Essentials 8.3 is now generally available, helping SOC teams simplify ...