Deployment Architecture

How to achieve renaming JSON field names?

dvuchev
Engager

Hey All,
wondering if I can get some input on this. I have data coming in as JSON. The fields follow this naming convention:

objects.Server::34385.fields.friendlyname = Server123
objects.Server::88634.fields.friendlyname = Server444

What I'm trying to do is to somehow rename the fields, so I omit the ::<number> after the Server part.
End result is needed to be like this:
objects.Server.fields.friendlyname = Server123
objects.Server.fields.friendlyname = Server444

It's worth mentioning that there are around 10k servers, so I can't list them out one by one.

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Try something like this

| foreach *::*.*
    [| eval "<<MATCHSEG1>>.<<MATCHSEG3>>" = if(isnotnull('<<FIELD>>'),'<<FIELD>>','<<MATCHSEG1>>.<<MATCHSEG3>>')]

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try something like this

| foreach *::*.*
    [| eval "<<MATCHSEG1>>.<<MATCHSEG3>>" = if(isnotnull('<<FIELD>>'),'<<FIELD>>','<<MATCHSEG1>>.<<MATCHSEG3>>')]
0 Karma

dvuchev
Engager

@ITWhisperer Thanks so much, was able to get what I needed with the | foreach

Marking as solution and DM 

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

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 ...