Dashboards & Visualizations

How to colour individual bar on a bar chart?

willsy
Communicator

Hello, 

I have a search that returns the status "UP" / "DOWN" for various groups. 
At the moment both UP and down are the same colour. 

how do i return the;
status=up green
status=down red

Edit ** Code
index=test host=ABC source=table.csv sourcetype=csv Group=Snow*
| eval Group=if(Group="Snow Day Here we come 12345","Snow",Group)
| eval Status=if(Status="Down (Acknowledged)", "Down", Status)
| dedup _raw
| stats count by Status

This gives me
Status                     Count
Down                      12
Up                            45

I would like those in a bar chart one column as red one as green

Labels (2)
Tags (2)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

You can't have different colours for bars in the same series, only different colours for different series.

0 Karma

yeahnah
Motivator

Hi @willsy 

It's often useful if you show your SPL code too as that sets the output which defines how the output will look in the chart.

Anyway, here's a run anywhere example of a bar chart with different colours for UP or DOWN

 

| makeresults | eval count="1 2", count=split(count, " ") | mvexpand count
| eval count=count%2
      ,status=if(count=1, "UP", "DOWN")
      ,count=1
 ``` SPL above creates dummy event ``` 
| chart max(count) OVER count BY status

 

yeahnah_0-1681850454675.png

Hope it helps to get you going

 

0 Karma

willsy
Communicator

I have put the search above, hopefully that helps.

0 Karma

yeahnah
Motivator

Try this...

index=test host=ABC source=table.csv sourcetype=csv Group=Snow*
| eval Group=if(Group="Snow Day Here we come 12345","Snow",Group)
| eval Status=if(Status="Down (Acknowledged)", "Down", Status)
| dedup _raw
| chart max(Count) OVER Count BY Status
| filldown
| tail 1
| eval Status=""
| table Status Down Up
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

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

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...