Splunk Search

Combining two searches to present a single percentage

aputz
Path Finder

I would like to be able to combine the following two searches or at least be able to reference the output of the searches to display them as a ratio or percentage of "count/sum(RX)" broken up by splunk indexers:

source="netstat" | chart sum(RX) by splunk_server

sourcetype="threats" | chart count by splunk_server

These searches both reference different sources and they currently are displayed by splunk indexer in a table.

Any help is much appreciated, thank you for any help.

Tags (1)
1 Solution

Stephen_Sorkin
Splunk Employee
Splunk Employee

I'd recommend using OR to combine the searches:

source=netstat OR sourcetype=threats
| eval RX = if(source="netstat", RX, null())
| eval is_threats = if(sourcetype="threats",1,0)
| stats sum(RX) as RX sum(is_threats) as count by splunk_server
| eval ratio = RX/count

View solution in original post

Stephen_Sorkin
Splunk Employee
Splunk Employee

I'd recommend using OR to combine the searches:

source=netstat OR sourcetype=threats
| eval RX = if(source="netstat", RX, null())
| eval is_threats = if(sourcetype="threats",1,0)
| stats sum(RX) as RX sum(is_threats) as count by splunk_server
| eval ratio = RX/count

aputz
Path Finder

That works like a charm. Thank you so much for your assistance!

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