Splunk Search

Regex to log will not contain anything

jrodriguezap
Contributor

Hello.
Appreciate your support, in the file transforms.conf REGEX try to make a log of all without "webfilter" and sent to nullQueue.
I tried to do something like this
[discard]
REGEX=!webfilter
DEST_KEY=queue
FORMAT=nullQueue

but it was not, then I tried:
[discard]
REGEX=.
DEST_KEY=queue
FORMAT=nullQueue
[maintain]
REGEX=webfilter
DEST_KEY=queue
FORMAT=indexQueue

But neither worked.
what would be the correct syntax for this case?
Thanks in advance

Tags (2)
0 Karma

lukejadamec
Super Champion

Try this. I'm only guessing at the regex because you have not posted an example of your event.

In Props.conf

[host::10.10.0.5]

TRANSFORMS-FORTIGATE=discard,maintain

In Transforms.conf
[discard]

REGEX=.

DEST_KEY=queue

FORMAT=nullQueue

[maintain]

REGEX=webfilter

DEST_KEY=queue

FORMAT=indexQueue

kristian_kolb
Ultra Champion

Then you should add an extra stanza in transforms.conf;

[null_dns_ssl]
REGEX = app=\"(DNS|SSL)\"
DEST_KEY = queue
FORMAT = nullQueue

And call it from props.conf like this (order is important)

TRANSFORMS-FORTIGATE = discard, maintain, null_dns_ssl

/K

jrodriguezap
Contributor

Ah ok, if so that's fine, so far I agree with Splunk.
Rather, now that I'm reviewing the result of the filter we did, there are some log that I would not be lost, and are those that do not contain the following: app="DNS" or app="SSL"
I tried to do like this: REGEX=webfilter|app=(?!"DNS|SSL]")
But it is showing me logs with app="DNS" or app="SSL"
I could be wrong?

0 Karma

lukejadamec
Super Champion

The solution I posted is the documented solution. How about we get it working first, and then optimize.

jrodriguezap
Contributor

Hello, thanks. The detail was separated with, aliases: TRANSFORMS-FORTIGATE = discard, Maintain
But tell me, the double REGEX would not do it with less optimal one, and the idea of lguinn? Maybe save some resources, right?

0 Karma

lguinn2
Legend

I think that the problem was the regular expression. This one is more complicated, but I think it will actually work. The other one was wrong.

In transforms.conf

[discard]
REGEX=(?i)(?!.*?webfilter) 
DEST_KEY=queue
FORMAT=nullQueue

In props.conf

[host::10.10.0.5]
TRANSFORMS-FORTIGATE_discard=discard

Note that in your comment, you have two transforms that start with TRANSFORMS-FORTIGATE and these should be unique. For example TRANSFORMS-FORTIGATE1 and TRANSFORMS-FORTIGATE2. I renamed my stanza above to make sure it was unique.

0 Karma

jrodriguezap
Contributor

Hi, thanks for your reply, I find interesting the syntax, but here now this filters all log me, and does not pass any 😞

0 Karma

jrodriguezap
Contributor

Hello, you will know what can be the problem?

0 Karma

jrodriguezap
Contributor

Hi, I have the following:
[host::10.10.0.5]
TRANSFORMS-FORTIGATE=discard
TRANSFORMS-FORTIGATE=maintain

I just want to keep the log that have "Webfilter"

0 Karma

lukejadamec
Super Champion

What do you have in the corresponding props.conf?
Also, an example of the event that contains "webfilter" would be handy.

0 Karma
Get Updates on the Splunk Community!

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

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 ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...