Getting Data In

How to configure props.conf to remove any line NOT containing a certain string?

essklau
Path Finder

Hi.

All I want is the props.conf equivalent of this delete action from sed:

'/pattern/!d' 

That is it... just delete ANY line NOT containing "pattern".

Any takers?

Tags (1)
1 Solution

aweitzman
Motivator

You can't use ^ as negation here. It's not a character class.

It might be easier to write two transforms, one that discards everything and one that keeps the ones you want:

props.conf
[your sourcetype]
TRANSFORMS-separate = discardall, keepsome

Order is important here. discardall comes first because all are applied in order, last one wins.

transforms.conf
[discardall]
REGEX=.*
DEST_KEY=queue
FORMAT=nullQueue

[keepsome]
REGEX=StringPattern
DEST_KEY=queue
FORMAT=indexQueue

View solution in original post

aweitzman
Motivator

You can't use ^ as negation here. It's not a character class.

It might be easier to write two transforms, one that discards everything and one that keeps the ones you want:

props.conf
[your sourcetype]
TRANSFORMS-separate = discardall, keepsome

Order is important here. discardall comes first because all are applied in order, last one wins.

transforms.conf
[discardall]
REGEX=.*
DEST_KEY=queue
FORMAT=nullQueue

[keepsome]
REGEX=StringPattern
DEST_KEY=queue
FORMAT=indexQueue

aweitzman
Motivator

Based on your comment, I promoted my comment so you could mark it as your answer.

0 Karma

essklau
Path Finder

settled to:

[setnull]
REGEX = .
DEST_KEY = queue
FORMAT = nullQueue

[setparsing]
REGEX = pattern
DEST_KEY = queue
FORMAT = indexQueue

pretty much weitzman's answer. Thanks!

strive
Influencer

transforms.conf

[strip_pattern_lines]
REGEX = StringPattern
DEST_KEY = queue
FORMAT = nullQueue

props.conf

[your sourcetype]
TRANSFORMS-tonullqueue = strip_pattern_lines

Dont forget to restart the splunk after making above changes.

Update:

transforms.conf

[strip_pattern_lines]
REGEX = ^(?:[^ ]* ){4}(?!(PATTERN))
DEST_KEY = queue
FORMAT = nullQueue

props.conf

[your_sourcetype]
TRANSFORMS-tonullqueue = strip_pattern_lines

strive
Influencer

I have edited my answer. Test regex once. I am not good at regex.

0 Karma

essklau
Path Finder

Sure:

2014-08-27 veryseriousinfo {zippity:boop.bop} hola23: PATTERN: Welcome to the jungle
2014-08-27 abunchofsilliness {bangarang:yes:arang} flip11: The news in Uganda is grim
2014-08-27 happygoluckyfool {drinkyourovaltine} lamp34: thisdoesnotmatter

I only want to index the lines containing "PATTERN"

0 Karma

strive
Influencer

Agree. Thats why i have asked for sample log lines, so that we can suggest right configurations

0 Karma

aweitzman
Motivator

(Just an FYI - This probably won't work on multiline events either, as @bmacias84 points out.)

0 Karma

strive
Influencer

Can you post your sample log lines which you want to send to null Queue

0 Karma

essklau
Path Finder

I tried

[strip_pattern_lines]
REGEX = ^StringPattern
DEST_KEY = queue
FORMAT = nullQueue

with no success yet.

0 Karma

bmacias84
Champion

I don't believe that this works on multiline events.

0 Karma

strive
Influencer

When you say delete, you do not want to index such lines. Is that right?

For this you need transforms.conf and props.conf

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...