Splunk Search

Edit data In Splunk

jokovitch
Explorer

I have a data in Splunk like

index="main"

FnameCountry
fname1USA
fname1USA
fname3USA

 

I want to add and change some data

where Fname="fname1"  I want to edit that Country = UK and add field of Phone =123

 

The final data will be

 

FnamePhone Country
fname1123UK
fname1123UK
fname3 USA

How can I do that?

Labels (1)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @jokovitch,

as @anilchaithu hinted, the correct search should be:

index=main
| eval Country=if(Fname="fname1","UK",Country), Phone=if(Fname="fname1","123","")
| table Fname Phone Country

if it doesn't run, check the fieldname (fields are case sensitive).

If doesn't run, please describe results and what's error.

Ciao.

Giuseppe

0 Karma

anilchaithu
Builder

@jokovitch 

you can use the below eval command for this task

eval Country = if(Fname="fname1", "UK", Fname), Phone= case(Fname="fname1", "123")

 

-- Hope this helps

0 Karma

jokovitch
Explorer
index="main" |eval Phone= case(Fname="fname1", "123")

I have tried this command , but nothing changed

0 Karma

anilchaithu
Builder

@jokovitch 

 

strange, try this. 

index="main" | eval Phone= case(like(Fname, "%fname1%", "123")

 

-- Hope this helps

0 Karma

jokovitch
Explorer

You need to change

 

index="main" | eval Phone= case(like(Fname, "%fname1%", "123")

 

to

 

index="main" | eval Phone= case(like(Fname, "%fname1%"), "123")

 

 

That still not change the data

 

Do I need to put this query in another place then New Search screen ? Or maybe is there place that I need to mark to commit this data?

 

 

0 Karma

jokovitch
Explorer

Do you have any idea how to fix that ?

0 Karma
Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...