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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...