Splunk Search

Multiple Evals with multiple values that requires renaming

Corey_Heart
Engager

Hello,

I understand that you can have two evals in one line but i keep getting several errors when i try to combine two.

This eval is going into the calculated field to pull info from another field as well.

 

Attempted Eval:

lower(if(isnull(action),attempted_action,action)), case(action == "OVERWRITTEN", "modified", action == "OPENED", "read", action == "DOES_NOT_EXIST", "deleted", action == "SUPERSEDED", "acl_modified", action == "CREATED", "created")

 

What am I trying to achieve?

We want the action to display the attempted action field when the action field is blank. With the attempted action values, there are about 7 values that will appear in the action field. I would like them to be renamed to make the CIM data models in some way. 

Labels (2)
0 Karma

to4kawa
Ultra Champion
| makeresults count=20 
| eval attempt_action="attempt" 
| eval action=mvindex(split("OverWritten,Opened,Does_Not_Exist,Superseded,Created,",","),random()% 6) 
| eval action=if(action="",NULL,action) 
| fields - _time
| rename COMMENT as "this is sample, how about this eval logic?"
| eval result=case(isnull(action),attempt_action,upper(action) == "OVERWRITTEN", "modified", upper(action) == "OPENED", "read", upper(action) == "DOES_NOT_EXIST", "deleted", upper(action) == "SUPERSEDED", "acl_modified", upper(action) == "CREATED", "created")

lower() can't work. try upper()

0 Karma

Corey_Heart
Engager

Thanks for the quick response.

The values that come back from both action & attempted_action fields are: 

Open
Set_security
Rename
Delete
Opened
Superseded
Created
Does_not_exist
Exists
Overwitten

 

However some of these values may come back in all caps. I am using the lower() to make all values come back in all lowercase.  Would this still work with lower or upper must still be used? 

0 Karma

to4kawa
Ultra Champion
| makeresults count=20 
| eval action=mvindex(split("OverWritten,Opened,Does_Not_Exist,Superseded,Created,",","),random()% 6) 
| eval attempt_action=mvindex(split("OverWritten,Opened,Does_Not_Exist,Superseded,Created",","),random()% 5) 
| eval action=if(action="",NULL,action) 
| fields - _time
| rename COMMENT as "this is sample, how about this eval logic?"
| eval action=upper(if(isnull(action),attempt_action,action))
| eval result=case(action="OVERWRITTEN", "modified",action="OPENED","read", action="DOES_NOT_EXIST", "deleted", action = "SUPERSEDED", "acl_modified", action = "CREATED", "created")

You used capitalized words(e.g. OVERWRITTEN), so I use upper()
lower()
lowercase letters. Which command you use is as you like. 

0 Karma

Corey_Heart
Engager

Thank you very much! this works

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...