Splunk Search

How don't we nullify the data?

danielbb
Motivator

A developer here wrote the following -

|eval admin_activity=if((like(cmd_data, "%audit%") AND like(cmd_data, "%start=%") AND NOT like(cmd_data, "%end=%")), "Login Attempt", NULL)
|eval admin_activity=if((like(cmd_data, "%audit%") AND like(cmd_data, "%start=%") AND like(cmd_data, "%end=%") AND isnull(admin_activity)), "Login Success", NULL)
|eval admin_activity=if((like(cmd_data, "%transaction%") AND isnull(admin_activity)), "Config Change", NULL)

We end up having admin_activity only as Config Change because the last eval nullifies the findings from the above two evals.

What can we do here?

Tags (1)
0 Karma
1 Solution

somesoni2
Revered Legend

Merge them in single eval-case , like this, so it stops overwriting value of admin_activity after first condition is true.

|eval admin_activity=case((like(cmd_data, "%audit%") AND like(cmd_data, "%start=%") AND NOT like(cmd_data, "%end=%")), "Login Attempt", (like(cmd_data, "%audit%") AND like(cmd_data, "%start=%") AND like(cmd_data, "%end=%") AND isnull(admin_activity)), "Login Success", (like(cmd_data, "%transaction%") AND isnull(admin_activity)), "Config Change", true(), null())

View solution in original post

Sukisen1981
Champion

hi @danielbb
You need to use a single eval

   |eval admin_activity=if((like(cmd_data, "%audit%") AND like(cmd_data, "%start=%") AND NOT like(cmd_data, "%end=%")), "Login Attempt", if((like(cmd_data, "%audit%") AND like(cmd_data, "%start=%") AND like(cmd_data, "%end=%") AND isnull(admin_activity)), "Login Success",if((like(cmd_data, "%transaction%") AND isnull(admin_activity)), "Config Change", NULL)))

somesoni2
Revered Legend

Merge them in single eval-case , like this, so it stops overwriting value of admin_activity after first condition is true.

|eval admin_activity=case((like(cmd_data, "%audit%") AND like(cmd_data, "%start=%") AND NOT like(cmd_data, "%end=%")), "Login Attempt", (like(cmd_data, "%audit%") AND like(cmd_data, "%start=%") AND like(cmd_data, "%end=%") AND isnull(admin_activity)), "Login Success", (like(cmd_data, "%transaction%") AND isnull(admin_activity)), "Config Change", true(), null())
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...