Splunk Search

Using regex, how to exclude any events in the host field and keep the rest?

some_guy
Path Finder

One big syslog file I need to index (monitor) daily. Many hosts log to this syslog file.

I want to exclude any events that contain 'server1' in the host field, and keep the rest.

On the receiving indexer, the following is in /opt/splunk/etc/system/local

props.conf:

[source::/syslog/Security/*.log]
TRANSFORMS-set = setnull, setparsing

transforms.conf:

[setnull]
REGEX = server1
DEST_KEY = queue
FORMAT = nullQueue
[setparsing]
REGEX = .
DEST_KEY = queue
FORMAT = indexQueue

Where might I have gone wrong? This does not seem to work.

0 Karma
1 Solution

lacastillo
Path Finder

Make sure to set your SOURCE_KEY = MetaData:Host under the [setnull] stanza in transforms.conf. That will get rid of the unwanted events, you shouldn't need the second stanza as the rest of the events that don't contain "server1" in the host field should get ingested per the rest of the parameters set in props.conf.

let me know if that helps.

View solution in original post

0 Karma

lacastillo
Path Finder

Make sure to set your SOURCE_KEY = MetaData:Host under the [setnull] stanza in transforms.conf. That will get rid of the unwanted events, you shouldn't need the second stanza as the rest of the events that don't contain "server1" in the host field should get ingested per the rest of the parameters set in props.conf.

let me know if that helps.

0 Karma

some_guy
Path Finder

Alleluia, its finally working!!! The key is, as you said:

SOURCE_KEY = MetaData:Host

THANKS!

0 Karma

lacastillo
Path Finder

You're very welcome!

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...