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!

Build the Future of Agentic AI: Join the Splunk Agentic Ops Hackathon

AI is changing how teams investigate incidents, detect threats, automate workflows, and build intelligent ...

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...