Dashboards & Visualizations

Charting 2 different stats query

RonD
Explorer

I am trying to achieve a simple pie chart that will display from two different stats query command

| inputlookup records.csv where condition1=compliant | stats count(host) as compliant
| append records.csv where (condition2=noncompliant AND condition3=noncompliant and condition4=noncompliant)| stats count(host) as noncompliant
| <I am missing a command at this point in able to produce the pie chart below>


compliance.PNG

Please advise. Thanks and regards.

Labels (1)
0 Karma
1 Solution

s2_splunk
Splunk Employee
Splunk Employee

Here's one approach:

 

| inputlookup records.csv 
| eval status=if( (condition1="noncompliant") OR (condition2="noncompliant" AND condition3="noncompliant" AND condition4="noncompliant"),"NC","C") 
| stats count(host) by status

 

Screen Shot 2020-12-15 at 1.02.41 PM.png 

BTW, you don't need a 

stats count(host)

 because you are just counting records, so 

stats count

would also work.

 

View solution in original post

RonD
Explorer

Thanks, this worked.

0 Karma

s2_splunk
Splunk Employee
Splunk Employee

Here's one approach:

 

| inputlookup records.csv 
| eval status=if( (condition1="noncompliant") OR (condition2="noncompliant" AND condition3="noncompliant" AND condition4="noncompliant"),"NC","C") 
| stats count(host) by status

 

Screen Shot 2020-12-15 at 1.02.41 PM.png 

BTW, you don't need a 

stats count(host)

 because you are just counting records, so 

stats count

would also work.

 

Get Updates on the Splunk Community!

SOC4Kafka - New Kafka Connector Powered by OpenTelemetry

The new SOC4Kafka connector, built on OpenTelemetry, enables the collection of Kafka messages and forwards ...

Your Voice Matters! Help Us Shape the New Splunk Lantern Experience

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

Building Momentum: Splunk Developer Program at .conf25

At Splunk, developers are at the heart of innovation. That’s why this year at .conf25, we officially launched ...