Splunk Search

placing conditions in regex

Jananee_iNautix
Path Finder

I have the following log format

13-11-22 00:03:06,124 [28c928c9] INFO: file abc.txt-ascii transferred

i want to transform the log into the following format
fri|november |11|2013|abc.txt|(a)

(a) which i mentioned above is the mode of the file either it will be in ascii or binary.if its binary (b) is displayed.

what will be the regex for this pattern in transforms.conf

Tags (1)
0 Karma

alacercogitatus
SplunkTrust
SplunkTrust

Possible, but I'd take a different approach. Firstly, Ayn is also correct. You probably shouldn't do that. But if you really want to:

Transforms.conf

[rewrite_data_sample]
SEDCMD-rewrite = s/(\d+-\d+-\d+\s[^\s]+)\s*\[\w+\]\s*([^:]*):\s*\w+\s*([^-]*)-(\w)\w+\s\w+/\1|\3|\4|\2/g
[extract_data_sample]
REGEX = ([^\|]*)\|([^\|]*)\|([^\|]*)\|([^\|]*)
FORMAT = date_raw::$1 filename::$2 filemode::$3 log_level::$4

Props.conf
[YOUR_SOURCETYPE]
TRANSFORMS-rewrite = rewrite_data_sample
REPORT-newdata = extract_data_sample

0 Karma

alacercogitatus
SplunkTrust
SplunkTrust

Make sure it is all on one line. Also, check my updated SED CMD.

0 Karma

Jananee_iNautix
Path Finder

This is not working.No transformation is done on the logs

0 Karma

Ayn
Legend

This is in my opinion beyond what you should be doing with basic regexes in Splunk. You should write a script that performs these transformations for you instead, as stuff like converting dates in the way you want are near to impossible to do with just regex. Things like determining the 13th is a Friday in a certain month without having strftime/strptime support would require some insane logic and conditions to get working in a regex.

Ayn
Legend

No. Read the docs.

0 Karma

Jananee_iNautix
Path Finder

To include and execute shell script in splunk,Should splunk be installed in UNIX

0 Karma

Ayn
Legend
0 Karma

Jananee_iNautix
Path Finder

can you say me the procedure to include and execute scripts in splunk.Also i have installed splunk in windows os

0 Karma

Jananee_iNautix
Path Finder

Thank you Ayn.You said with scripts I can perform transformation.Can you say how to do that in splunk.

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...