Splunk Search

Does transforms.conf support a regex group based rerouting?

paimonsoror
Builder

Hi all;

I am trying to build some logic for a docker/k8s integration that we are doing through fluentd. Basically we are testing one avenue of this integration utilizing fluentd -> splunk. One of the things we want to be able to do, is to leverage a field in the json payload called 'namespace' to separate the data into its own index. Right now, here is the setup of my inputs.conf

[tcp:1520]
connection_host = dns
index = app_cpceng
sourcetype = fluentd_json
acceptFrom = xx.xx.xx.xx

Now i know utilizing transforms we can do something like this:

[routemyhosttomynewindex]
SOURCE_KEY = MetaData:Host
REGEX = myhost
DEST_KEY = MetaData:Index
FORMAT = mynewindex

where in this example it reroutes the data to an alertnate index based on the hostname, but is it possible for me to do something like this:

[routemyhosttomynewindex]
SOURCE_KEY = MetaData:Raw (not sure if that is the correct meta name)
REGEX = \"namespace\":\"(\w+)\"
DEST_KEY = MetaData:Index
FORMAT = app_cpceng_$1

A very crude example above, but hopefully it illustrates what I am looking for.

0 Karma
1 Solution

somesoni2
Revered Legend

The default SOURCE_KEY is _raw so, just exclude that in your transforms.conf stanza, ensure regex is correct and it should work fine.
Reference, (REGEX per your need)
https://answers.splunk.com/answers/246672/how-can-i-override-an-index-name-based-on-sourcety.html

View solution in original post

0 Karma

somesoni2
Revered Legend

The default SOURCE_KEY is _raw so, just exclude that in your transforms.conf stanza, ensure regex is correct and it should work fine.
Reference, (REGEX per your need)
https://answers.splunk.com/answers/246672/how-can-i-override-an-index-name-based-on-sourcety.html

0 Karma

paimonsoror
Builder

Good to know, thanks for the info. One of my curiosities was if I could use regex group captures within the FORMAT field, but based on : https://answers.splunk.com/answers/326378/can-i-do-named-capture-in-transformsconf-format-ip.html it looks like I can, so i think my question is answered 🙂

0 Karma

sbbadri
Motivator
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...