Splunk Search

Can I rename different fields the same thing?

Federica_92
Communicator

I'm working with a dataset that lists companies and individual people, so that some entries have the field "Entity Name" and some have "Individual Name". I'd like to output a table with both of these fields shown under a single "Name" field. When I try to rename them both by this title, though, the second command overwrites the first one. Is there a way to have both fields listed under the same title, while keeping them as separate events?

Tags (3)
1 Solution

Runals
Motivator

I often use coalesce in these cases; hopefully it will work in yours.

... | eval name = coalesce(entityName, individualName) | ... 

This assumes every event will have either one or the other field. Otherwise I think if it has both it will grab the fields in the order listed. I often use that for especially Windows logs where the field used might be different for the same type of event based on OS version or specific event ID.

View solution in original post

Robwhoa78
Explorer

What if you have multiple that you want to rename the same?

| rename "Message.TaskInfo.CarHop Backup.LastResult"="-2147020576" AS Result
| rename "Message.TaskInfo.CarHop Backup.LastResult"=1 AS Result
| rename "Message.TaskInfo.CarHop Backup.LastResult"=0 AS Result
| rename "Message.TaskInfo.AI Restart Weekly.LastResult"=267011 AS Result
| rename "Message.TaskInfo.CarHop Backup.LastResult"=267009 AS Result
| rename "Message.TaskInfo.CarHop Backup.LastResult"=2 AS Result

This is not working for me

 

0 Karma

stephane_cyrill
Builder

Hi Federica_92,

I the following can solve your problem:

.........|eval SingleName=mvzip(entityName, individualName)| makemv delim="," SingleName|mvexpand SingleName

For Example if you want to have both host and soure in the same field call SingleName :

index=*|table host source|eval SingleName=mvzip(host,source)| makemv delim="," SingleName|mvexpand SingleName

I hope you will be satisfied.

fdi01
Motivator

u can try like this:
... |rename entityName as Name |eval Name ="companie name:" + Name + "and people name:" + individualName | ...

NOUMSSI
Builder

Hi,
Try this

...|rename "Entity Name"  as EntityName| rename "Individual Name"  as IndividualName |eval name=EntityName  +  IndividualName |...

Runals
Motivator

I often use coalesce in these cases; hopefully it will work in yours.

... | eval name = coalesce(entityName, individualName) | ... 

This assumes every event will have either one or the other field. Otherwise I think if it has both it will grab the fields in the order listed. I often use that for especially Windows logs where the field used might be different for the same type of event based on OS version or specific event ID.

Runals
Motivator

Another way to do it might be something like

... | eval name = if(isnotnull(entityName), entityName, individualName) | ...
0 Karma
Get Updates on the Splunk Community!

Take Your Breath Away with Splunk Risk-Based Alerting (RBA)

WATCH NOW!The Splunk Guide to Risk-Based Alerting is here to empower your SOC like never before. Join Haylee ...

SignalFlow: What? Why? How?

What is SignalFlow? Splunk Observability Cloud’s analytics engine, SignalFlow, opens up a world of in-depth ...

Federated Search for Amazon S3 | Key Use Cases to Streamline Compliance Workflows

Modern business operations are supported by data compliance. As regulations evolve, organizations must ...