Splunk Search

How to debug transforms.conf regex errors

huaraz
Explorer

Hi

I have a logfile with different formated lines and I want to extract comon fields . My props.conf looks like:

[mylog]
TRUNCATE=0
SHOULD_LINEMERGE=false
TIME_PREFIX=(
TRANSFORMS-header_null_queue=send_header_to_nullqueue
REPORT-main=type1, type2, type3
TIME_FORMAT=%s.%6N

[send_header_to_nullqueue]
REGEX = ^#
DEST_KEY = queue
FORMAT = nullQueue

[type1]
REGEX=...

[type2]
REGEX=..

[type3]
REGEX=..

I checked using pcregextest that each regex works for my 3 types of log lines. But all together seems not to work as I don't get the fields.

Thank you
Markus

0 Karma

Runals
Motivator

I use regex101.com. Just to confirm though because it isn't in your examples

1) do your REGEX lines exist in your props.conf or your transforms.conf? Your send_header_to_nullqueue, type1 - type3 stanzas need to live in a transforms.conf
2) do your REGEX lines in type1 - 3 have a capturing group with a field name in them? For example

REGEX= I want (foo) for breakfast

has a capturing group but there is no defined field. You could do one of the approaches below

REGEX = I want (?<breakfast_food>foo) for breakfast
or
REGEX = I want (?<breakfast_food>\S) for breakfast

OR

REGEX = I want (foo) for breakfast
FORMAT = breakfast_food::$1

0 Karma

woodcock
Esteemed Legend

I use expresso:
http://www.ultrapico.com/expresso.htm

This tool allows you to paste your log text as-is into one window and paste your REGEX as-is into another window and check the results. If your REGEXs work in expresso then either there is something wrong with your configuration file organization or your (possibly incorrect expectations of) search.

0 Karma
Get Updates on the Splunk Community!

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...