Splunk Search

pie chart

schufi01
Path Finder

Hi,

I got a splunk search that monitors, how many different hosts there were in the chosen timespan. 

| stats dc(host) as hostcount

Now I would like to generate a pie chart, that compares succesful hosts with the unseccesful ones. Therefore I got a field "errors". All hosts with error > 50 should be counted as unseccesful. The others should be counted as succesful. The pie chart should show the succesful/unsuccesful ratio. 

Labels (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| makeresults | eval _raw="host  errors
abc              
def      50               
ghi      51
abc      2      
def      50               
ghi      51" | multikv forceheader=1 | fields - _raw _time linecount


| eval unsuccessful = if(errors > 50, "unsuccessful", null)
| stats values(unsuccessful) as unsuccessful by host
| eval status=if(unsuccessful = "unsuccessful","unsuccessful", "successful")
| stats count by status

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust
| stats sum(errors) as errortotal by host
| eval status=if(errortotal > 50,"unsuccessful", "successful")
| stats count by status
0 Karma

schufi01
Path Finder

Thank you, that already helps. However I did a mistake while explaining my situation. I dont want the sum of errors to be  > 50. If there was one event with error >50 within the timespan, the host should be classified unsuccesful. The sum of errors per host is not important for me. Only if there was one single event with error >50. Do you understand what I mean?

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| makeresults | eval _raw="host  errors
abc              
def      50               
ghi      51
abc      2      
def      50               
ghi      51" | multikv forceheader=1 | fields - _raw _time linecount


| eval unsuccessful = if(errors > 50, "unsuccessful", null)
| stats values(unsuccessful) as unsuccessful by host
| eval status=if(unsuccessful = "unsuccessful","unsuccessful", "successful")
| stats count by status
Get Updates on the Splunk Community!

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...