All Apps and Add-ons

rename clobbers existing field with that name

alexl1
Path Finder

hi, is there a way to rename a splunk field but that if the field name already exists it won't get clobbered?

E.g.
let's say some events have a field called oldfield and some already have a field called newfield

I want oldfield to get renamed but if newfield exists (and I know old field won't exist if it does) then I want that to be newfield

thanks,

Tags (1)
0 Karma
1 Solution

acharlieh
Influencer

Instead of rename, you could use an eval to determine the value, and then just remove the oldfield.

| eval newfield=coalesce(newfield,oldfield) | fields - oldfield

View solution in original post

acharlieh
Influencer

Instead of rename, you could use an eval to determine the value, and then just remove the oldfield.

| eval newfield=coalesce(newfield,oldfield) | fields - oldfield

lmonahan
Path Finder

Outrageous trick!  Very helpful, thank you!  😀

0 Karma

alexl1
Path Finder

thanks! ..

0 Karma

alexl1
Path Finder

(I used to know how to do it but I forgot)

0 Karma
Get Updates on the Splunk Community!

Upcoming Webinar: Unmasking Insider Threats with Slunk Enterprise Security’s UEBA

Join us on Wed, Dec 10. at 10AM PST / 1PM EST for a live webinar and demo with Splunk experts! Discover how ...

.conf25 technical session recap of Observability for Gen AI: Monitoring LLM ...

If you’re unfamiliar, .conf is Splunk’s premier event where the Splunk community, customers, partners, and ...

A Season of Skills: New Splunk Courses to Light Up Your Learning Journey

There’s something special about this time of year—maybe it’s the glow of the holidays, maybe it’s the ...