Splunk Search

How to normalize events with multiple keys?

jrich523
Path Finder

I have a couple of fields, Node and NodeID, which will both have a number. Then I have NodeName which is of the format "Node001", so to make sure they all have a NodeName, I did this

eval NodeName="Node".substr("000".NodeId,-3) | eval NodeName = "Node".substr("000".Node,-3)

However, this seems rather wasteful. How would I combine this into one statement? It's unlikely an event will have both Node and NodeID, but I'd have to dig through the data more

0 Karma

sundareshr
Legend

Try this

.... | eval NodeName="Node".substr("000", coalesce(NodeId, Node), -3)
0 Karma
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...