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!

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...