Dashboards & Visualizations

How to color the bar chart of a field based on other field value?

SG
Path Finder

Hello,

Need help in coloring the bar chart of a field based on the other field value? Below is my sample search

 

 

index=nextgen sourcetype=lighthouse_json datasource=LH step="http://www.google.com/" 
| stats  values(speedindex) as speedindex by _time

 

 

Sample log for the above search

SG_0-1620644952639.png

and visualization for the above query...

SG_1-1620645018728.png

I wanted to color the bars of the speed index based on the score? For example in the above screenshot speedindex_score is 89, which means the page is performing good and I wanted to get that bar in green color.

If 

speedindex_score is in between 0-49 - Red color

speedindex_score is in between 50-89 - yellow color

speedindex_score is in between 90-100 - Green color

Can someone please help me with how to plot in the above mentioned manner?

 

Labels (1)
Tags (1)
0 Karma
1 Solution

SG
Path Finder

With the below, I am able to color the bar charts based on the score field value. For the colors I edited XML.

index=nextgen sourcetype=lighthouse_json datasource=LH step="https://www.google.com/"
| stats values(speedindex) as speedindex, values(speedindex_score) as score by _time

| eval green = if(score>=90 AND score<=100,speedindex,0)
| eval yellow = if(score<=89 AND score>50,speedindex,0)
| eval red = if(score<=49 AND score>0,speedindex,0)
| fields - speedindex,score

 

View solution in original post

0 Karma

SG
Path Finder

With the below, I am able to color the bar charts based on the score field value. For the colors I edited XML.

index=nextgen sourcetype=lighthouse_json datasource=LH step="https://www.google.com/"
| stats values(speedindex) as speedindex, values(speedindex_score) as score by _time

| eval green = if(score>=90 AND score<=100,speedindex,0)
| eval yellow = if(score<=89 AND score>50,speedindex,0)
| eval red = if(score<=49 AND score>0,speedindex,0)
| fields - speedindex,score

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Charts are coloured by series, e.g. all bars in the same series are the same colour, therefore, to get different colours, you need to split your data into different series.

0 Karma

SG
Path Finder

Hi, I changed the query to get data into 2 different series

index=nextgen sourcetype=lighthouse_json datasource=LH step="http://www.google.com/" 
| stats  values(speedindex) as speedindex, values(speedindex_score) as score by _time

Below is the sample data 

SG_0-1620646873055.png

Now I devided data into 2 different series, can you please help me with how to color the bar chart of speedindex based on score value?

Tags (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

https://docs.splunk.com/Documentation/SplunkCloud/8.2.2104/Viz/BuildandeditdashboardswithSimplifiedX...

However, your search doesn't split the values of the field into different series by range. You should evaluate copies of the values into new fields based on the value of the original field falling into the ranges you want.

| eval low=if(speedindex_score<50,speedindex_score,null)
| eval medium=if(speedindex_score>=50 AND speedindex_score <90,speedindex_score,null)
| eval high=if(speedindex_score>=90,speedindex_score,null)
Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Get the T-shirt to Prove You Survived Splunk University Bootcamp

As if Splunk University, in Las Vegas, in-person, with three days of bootcamps and labs weren’t enough, now ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...