Getting Data In

Is it possible to create an if/else statement with the TRANSFORMS_ field into props.conf file ?

Zanusha443
Explorer

I have data coming from a single source

but I want to send the events that match a REGEX to an index and all the other that not match it to another index.


I have already tried to change the order of the fields into the TRANSFORMS_ but it still put the events in both indexes.
This is the content of the props.conf file:

[tmpproxy]

TRANSFORMS_routing1 =CIDR_Routing_matched, CIDR_Routing_others

and this is the content of the transforms.conf file:

[CIDR_Routing_matched]
REGEX =src_host\=(?:10\.10\.10\.\d{1,3}|)
FORMAT = tmp_matched_proxy
DEST_KEY=_MetaData:Index
WRITE_META=true

[CIDR_Routing_others]
REGEX =.+
FORMAT = tmp_others_proxy
DEST_KEY=_MetaData:Index
WRITE_META=true

Is it possible to stop the TRANSFORMS_ field in the props.conf file after the first good match?

Labels (3)
Tags (1)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @Zanusha443 ,

you have to set in the inputs.conf the index that doesn't match the regex.

Then on Indexers, or (if present) in Heavy Forwarders, you have to override index value using props.conf and transforms.conf.

in props.conf:

[your_sourcetype]
TRANSFORMS-index = overrideindex

in transforms.conf:

[overrideindex]
DEST_KEY =_MetaData:Index
REGEX = src_host\=(?:10\.10\.10\.\d{1,3}|)
FORMAT = my_new_index

supponing that src_host\=(?:10\.10\.10\.\d{1,3}|) is the regex for events to be sent to the other index.

Beware to the location of these files: if you have one or more intermediate Heavy Forwarders, you have to put them on the first HF, if there isn't any HF, you have to put them on Indexers.

Ciao.

Giuseppe

 

View solution in original post

gcusello
SplunkTrust
SplunkTrust

Hi @Zanusha443 ,

you have to set in the inputs.conf the index that doesn't match the regex.

Then on Indexers, or (if present) in Heavy Forwarders, you have to override index value using props.conf and transforms.conf.

in props.conf:

[your_sourcetype]
TRANSFORMS-index = overrideindex

in transforms.conf:

[overrideindex]
DEST_KEY =_MetaData:Index
REGEX = src_host\=(?:10\.10\.10\.\d{1,3}|)
FORMAT = my_new_index

supponing that src_host\=(?:10\.10\.10\.\d{1,3}|) is the regex for events to be sent to the other index.

Beware to the location of these files: if you have one or more intermediate Heavy Forwarders, you have to put them on the first HF, if there isn't any HF, you have to put them on Indexers.

Ciao.

Giuseppe

 

Get Updates on the Splunk Community!

Get the T-shirt to Prove You Survived Splunk University Bootcamp

As if Splunk University, in Las Vegas, in-person, with three days of bootcamps and labs weren’t enough, now ...

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...