Splunk Search

When changing host value using transforms.conf, how do I set the host value to something based on a regex?

dfetcher
Engager

I'm very new to Splunk. I'm trying to use transforms.conf and props.conf to set the host value to something based on a regex. Every time I try it, the host value is always set to $1.

This is my transforms.conf

[setHost]
DEST_KEY = MetaData:Host
SOURCE_KEY = MetaData:Source
REGEX = webserver\d{0,2}-\d{0,3}
FORMAT = host::"$1"

This is my props.conf

[iis]
TRANSFORMS-setHost = setHost

The source that it's coming from looks like this /var/logs/webserver01-003/blah.log

How do I get this to work?

Thank you.

Tags (1)
0 Karma
1 Solution

FrankVl
Ultra Champion

Or much simpler: set host_segment = 3 in inputs.conf and you can forget about that whole TRANSFORMS stuff 🙂

View solution in original post

FrankVl
Ultra Champion

Or much simpler: set host_segment = 3 in inputs.conf and you can forget about that whole TRANSFORMS stuff 🙂

martin_mueller
SplunkTrust
SplunkTrust

Remove the double quotes around $1 in your FORMAT, and add a capturing group to your REGEX around whatever you want the host value to be. $1 refers to the first capturing group, without a capturing group there's nothing to refer to.

Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...