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
Get Updates on the Splunk Community!

Index This | Why did the turkey cross the road?

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

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  🚀 Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Feel the Splunk Love: Real Stories from Real Customers

Hello Splunk Community,    What’s the best part of hearing how our customers use Splunk? Easy: the positive ...