Getting Data In

Is there any way to execute SEDCMD after transforms are applied?

bergs
Engager

Hi,

As far as I understand, SEDCMD is executed before TRANSFORMS.
Is there any way to make it execute after?

I'm overriding some metadata fields based on the content of a event. Current (simplified) working configs:

transforms.conf

[add_host]
REGEX = fetchinghost
FORMAT = host::$1
DEST_KEY = MetaData:Host

props.conf

[default]
TRANSFORMS-addinghost = add_host

Now, I would like to remove (or anonymize if you will) host from the original event, after it's been written to the host field. Current config, where SEDCMD works fine, but where TRANSFORMS does not (as i suppose SEDCMD removes/alters the event before TRANSFORMS' regex gets to it):

props.conf

[default]
TRANSFORMS-addinghosttometadata = add_host
SEDCMD-removinghostfromevent = s/fetchinghost/nothinghere/g

I've played around with setting priority, but with no luck.

Any help or tips would be greatly appreciated.

0 Karma
1 Solution

hunters_splunk
Splunk Employee
Splunk Employee

Hi bergs,

I think you should create another stanza in transforms.conf in the same way you performed the host overriding. Something like this:

props.conf

TRANSFORMS-1addinghost = add_host
TRANSFORMS-2removinghost = remove_host

transforms.conf

[add_host]
 REGEX = fetchinghost
 FORMAT = host::$1
 DEST_KEY = MetaData:Host

[remove_host]
 REGEX = (pattern before host)hostname(pattern after host)
 FORMAT = $1XXX$2
 DEST_KEY = _raw

You use regex to capture patterns before and after the host name in your data and replace the hostname part in FORMAT.

Hope this helps. Thanks!
Hunter

View solution in original post

hunters_splunk
Splunk Employee
Splunk Employee

Hi bergs,

I think you should create another stanza in transforms.conf in the same way you performed the host overriding. Something like this:

props.conf

TRANSFORMS-1addinghost = add_host
TRANSFORMS-2removinghost = remove_host

transforms.conf

[add_host]
 REGEX = fetchinghost
 FORMAT = host::$1
 DEST_KEY = MetaData:Host

[remove_host]
 REGEX = (pattern before host)hostname(pattern after host)
 FORMAT = $1XXX$2
 DEST_KEY = _raw

You use regex to capture patterns before and after the host name in your data and replace the hostname part in FORMAT.

Hope this helps. Thanks!
Hunter

bergs
Engager

Thanks Hunter,

This was exactly what I needed 🙂

0 Karma

somesoni2
Revered Legend

Can you try performing your data anonymization in transforms.conf only.

https://docs.splunk.com/Documentation/Splunk/6.5.1/Data/Anonymizedata#Configure_transforms.conf

0 Karma
Get Updates on the Splunk Community!

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...

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