Dashboards & Visualizations

Could you help me build a bar chart?

stevesmith08
Explorer

Hey,

Could you please help me?

Suppose I have events like this:

alt text

Each event contains a student's assessment in five disciplines.

The assessment is considered unsatisfactory if the student scored less than 50 points.

You want to write a query that allows you to build a diagram of the following form:

alt text

Thanks so much!

Tags (1)
0 Karma
1 Solution

renjith_nair
Legend

@stevesmith08,

Assuming you have your current search as

index="your index" | table Surname,Math,Physics, History, IT, PE

Lets untable it to get the Marks as a column and Subject as rows for calculation.

   index="your index" | table Surname,Math,Physics, History, IT, PE
   |untable Surname,Subject,Marks

And now do a conditional stats count : FINAL

   index="your index" | table Surname,Math,Physics, History, IT, PE
   |untable Surname,Subject,Marks
   |stats count(eval(Marks>50)) as "COUNT(>50)", count(eval(Marks<50)) as "COUNT(<50)" by Subject

Run anywhere example

index=_* earliest=-6m|timechart span=2m count as Marks by sourcetype|rename sourcetype as Subject,_time as Surname
|untable Surname,Subject,Marks
|stats count(eval(Marks>50)) as "COUNT(>50)", count(eval(Marks<50)) as "COUNT(<50)" by Subject
---
What goes around comes around. If it helps, hit it with Karma 🙂

View solution in original post

renjith_nair
Legend

@stevesmith08,

Assuming you have your current search as

index="your index" | table Surname,Math,Physics, History, IT, PE

Lets untable it to get the Marks as a column and Subject as rows for calculation.

   index="your index" | table Surname,Math,Physics, History, IT, PE
   |untable Surname,Subject,Marks

And now do a conditional stats count : FINAL

   index="your index" | table Surname,Math,Physics, History, IT, PE
   |untable Surname,Subject,Marks
   |stats count(eval(Marks>50)) as "COUNT(>50)", count(eval(Marks<50)) as "COUNT(<50)" by Subject

Run anywhere example

index=_* earliest=-6m|timechart span=2m count as Marks by sourcetype|rename sourcetype as Subject,_time as Surname
|untable Surname,Subject,Marks
|stats count(eval(Marks>50)) as "COUNT(>50)", count(eval(Marks<50)) as "COUNT(<50)" by Subject
---
What goes around comes around. If it helps, hit it with Karma 🙂

richgalloway
SplunkTrust
SplunkTrust

This query should produce the desired results. After running it, choose "Stacked Column" from the Visualizations tab.

| stats count(eval(points>50)) as "COUNT(>50)", count(eval(points<=50)) as "COUNT(<=50)" by discipline
---
If this reply helps you, Karma would be appreciated.
0 Karma

stevesmith08
Explorer

Sorry, but what information do the “points” and “discipline” fields store?

I may not have accurately put it, but the structure of each event is as follows:
Surname = Smith, Math = 100, Physics = 65, History = 35, IT = 58, PE = 45
Surname = Wilson, Math = 67, Physics = 60, History = 90, IT = 72, PE = 50
...

But your way is really good for a bar chart on each subject individually 🙂

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Points are scores and disciplines are subjects, using the terms in your OP. My answer is completely invalidated by your comment giving the event format. renjith.nair's answer appears to have nailed it.

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...