Splunk Search

how to display raw result if no specific result is available?

jalfrey
Communicator

I'm doing a pretty basic search which looks for a "connection closed" message and displays a variable called app. I have an automatic lookup which converts the app value to an application name. Not all of the values can be looked up in my lookup table. How do I run a search and display the application name (app_name) and if that's not available then display the app (numeric value)?

Here is the search I have made that calculates bytes sent/received and displays bot the app name and the app numeric value.

app=* "Connection Closed" | stats sum(sent) sum(rcvd) by dst_ip app | lookup sonicwall_app_id app_id as app OUTPUT app_name as Application | fields dst_ip, Application, app, sum(sent), sum(rcvd) | rename dst_ip as "Destination IP" | rename app to "App ID" | rename sum(sent) as "Bytes Sent" | rename sum(rcvd) as "Bytes Received"

Tags (2)
0 Karma
1 Solution

Ayn
Legend

Create a field that uses either the app_name if it's not null, otherwise use app_id:

... | eval yournewfield = coalesce(app_name, app_id) | ...

View solution in original post

Ayn
Legend

Create a field that uses either the app_name if it's not null, otherwise use app_id:

... | eval yournewfield = coalesce(app_name, app_id) | ...

Rob
Splunk Employee
Splunk Employee

+1 on a nice use of coalesce!

0 Karma

jalfrey
Communicator

my final search looks like:

index=sonicwall app=* "Connection Closed" | stats sum(sent) sum(rcvd) by dst_ip app | lookup sonicwall_app_id app_id as app OUTPUT app_name | eval "Application" = coalesce(app_name, app) | fields dst_ip, "Application", sum(sent), sum(rcvd) | rename dst_ip as "Destination" | rename sum(sent) as "Sent Bytes" | rename sum(rcvd) as "Received Bytes"

0 Karma

jalfrey
Communicator

that worked great! Thanks.

0 Karma
Get Updates on the Splunk Community!

Enterprise Security Content Update (ESCU) | New Releases

In December, the Splunk Threat Research Team had 1 release of new security content via the Enterprise Security ...

Why am I not seeing the finding in Splunk Enterprise Security Analyst Queue?

(This is the first of a series of 2 blogs). Splunk Enterprise Security is a fantastic tool that offers robust ...

Index This | What are the 12 Days of Splunk-mas?

December 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...