Splunk Search

transforms the source to remove timestamp

mataharry
Communicator

I want to change the source filename for my data to remove the timestamp.

from mypath\to\my\folder\userentrypoint17_20110309T143708_170500.log to mypath\to\my\folder\userentrypoint17.log

the timestamp in the filename is not used, because the complete timestamp is precsent in each event.

Tags (2)
1 Solution

yannK
Splunk Employee
Splunk Employee

Here is the method.

On the indexer side (or the regular forwarder)

in /local/props.conf
[sourcetypeofyourdata]
TRANSFORMS-changesource = removetimestamp

in /local/transforms.conf
[removetimetamp]
SOURCE_KEY = MetaData:Source
DEST_KEY = MetaData:Source
REGEX = (.*?)(_\d{8}T\d{6}_\d{6})(\.log)
#use a regex to extract the filename
FORMAT = source::$1$3

to explain here is the regex in action : mypath\userentrypoint17_20110309T143708_170500.log
is cut in 
$1: mypath\userentrypoint17
$2: _20110309T143708_170500
$3: .log 
and we throw away the $2 

View solution in original post

Lowell
Super Champion

You may find some of the transformer examples here helpful as well:

http://splunk-base.splunk.com/answers/3470/consolidate-similarly-named-log-files-into-a-single-sourc...

yannK
Splunk Employee
Splunk Employee

Here is the method.

On the indexer side (or the regular forwarder)

in /local/props.conf
[sourcetypeofyourdata]
TRANSFORMS-changesource = removetimestamp

in /local/transforms.conf
[removetimetamp]
SOURCE_KEY = MetaData:Source
DEST_KEY = MetaData:Source
REGEX = (.*?)(_\d{8}T\d{6}_\d{6})(\.log)
#use a regex to extract the filename
FORMAT = source::$1$3

to explain here is the regex in action : mypath\userentrypoint17_20110309T143708_170500.log
is cut in 
$1: mypath\userentrypoint17
$2: _20110309T143708_170500
$3: .log 
and we throw away the $2 
Get Updates on the Splunk Community!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...