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!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...