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
and visualization for the above query...
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?
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
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
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.
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
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?
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)