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!

Take Your Breath Away with Splunk Risk-Based Alerting (RBA)

WATCH NOW!The Splunk Guide to Risk-Based Alerting is here to empower your SOC like never before. Join Haylee ...

Industry Solutions for Supply Chain and OT, Amazon Use Cases, Plus More New Articles ...

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

Enterprise Security Content Update (ESCU) | New Releases

In November, the Splunk Threat Research Team had one release of new security content via the Enterprise ...