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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Index This | What travels the world but is also stuck in place?

April 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...