All Apps and Add-ons

Changing field names at runtime

mmmmssss
Engager

Hi,

I cant find a good way to rename multiple field names within different datatypes at run time to then be able to apply transactions to them.

Here is an example:

search * | rename SourceNetworkAddress as IP | stats count by IP

This gives me 4 different IP's with 39 distinct events

if I change it to

search * | rename SourceNetworkAddress as IP, IP_Address as IP | stats count by IP

The second value seems to overwrite the first and I end up with 2 different IP addresses with 12 distinct events. I guess because the first event type doesnt contain that fieldname it is just being overwritten to blank.

I have got around it in the interim by just renaming the first field to the name of the second, but this isnt flexible as I now want to add a third datatype.

Any help appreciated! Thanks,

1 Solution

Ayn
Legend

You could use eval's coalesce() function instead. It will take a variable number of parameters and return the first one that is not null.

search * | eval IP=coalesce(SourceNetworkAddress, IP_Address, ..., ...) | stats count by IP

View solution in original post

Ayn
Legend

You could use eval's coalesce() function instead. It will take a variable number of parameters and return the first one that is not null.

search * | eval IP=coalesce(SourceNetworkAddress, IP_Address, ..., ...) | stats count by IP
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Agent Mode Engaged! Enchaining Agentic Operations with Splunk AI Assistant 2.0

    Are you ready to transform how your team handles complex data requests? We invite you to our upcoming ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...