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!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...