Splunk Search

help with eval command

super_saiyan
Communicator

Hi everyone, i want to use the below command in a single line. i have tried "comma" but it's not working.

How do i do it?

|eval comments= if(Action="create","something has been created",'comments')
|eval comments= if(Action="delete","something  has been deleted",'comments')


Thanks.

Labels (1)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @super_saiyan,

yes sorry!

| eval comments= if(Action="create","something has been created", if(Action="delete","something  has been deleted",'comments'))

does it run and solves your need?

Ciao.

Giuseppe

View solution in original post

somesoni2
SplunkTrust
SplunkTrust

Use the case command, like this

|eval comments= case(Action="create","something has been created", Action="delete","something  has been deleted", true(),'comments')

The option "true()" is for default option (when all preceding conditions do not match).

gcusello
SplunkTrust
SplunkTrust

Hi @super_saiyan,

use two concatenated ifs:

| eval comments= if(Action="create","something has been created", if(Action="delete","something  has been deleted",'comments')

or case with the same logic

Ciao.

Giuseppe

super_saiyan
Communicator

There is a closing bracket " ) " missing in the SPL.
is it supposed to be that way ? 
@gcusello 

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @super_saiyan,

yes sorry!

| eval comments= if(Action="create","something has been created", if(Action="delete","something  has been deleted",'comments'))

does it run and solves your need?

Ciao.

Giuseppe

super_saiyan
Communicator

Yes, It ran and solved my issue. Thank you so much as always.
@gcusello 

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