Dashboards & Visualizations

how to show different colors for each bar in bar chart

ramki1459
Explorer
|query
| stats count by app_status| eventstats sum(count) as totalCount 
| eval percentage=round((count/totalCount)*100,3)
| fields - count totalCount
| chart max(percentage) by app_status

i want to show results in bar chart. with above query i am able to see the bar chart, but all bars have same color. is there way to show different colors for each bar? thanks in advance

Tags (1)
0 Karma
1 Solution

niketn
Legend

@ramki1459, try the following search.

<yourBaseSearch>
| top 0 app_status showcount=f
| transpose 0 header_field="app_status" column_name="app_status" 
| search component!="_*" 
| chart max(percentage) by app_status

PS: I have used limit=0 to show maximum allowed fields. However, you can use specific number if you know what could be the upper limit for unique app_status field values. The following run anywhere example based on Splunk's _internal index shows only 5 of all the components.

index=_internal sourcetype=splunkd log_level!="INFO" component!="Metrics" OR component!="PeriodicHealthChecker" 
| top 5 component showcount=f 
| transpose 5 header_field="component" column_name="component" 
| search component!="_*"

Please try out and confirm!

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

0 Karma

niketn
Legend

@ramki1459, try the following search.

<yourBaseSearch>
| top 0 app_status showcount=f
| transpose 0 header_field="app_status" column_name="app_status" 
| search component!="_*" 
| chart max(percentage) by app_status

PS: I have used limit=0 to show maximum allowed fields. However, you can use specific number if you know what could be the upper limit for unique app_status field values. The following run anywhere example based on Splunk's _internal index shows only 5 of all the components.

index=_internal sourcetype=splunkd log_level!="INFO" component!="Metrics" OR component!="PeriodicHealthChecker" 
| top 5 component showcount=f 
| transpose 5 header_field="component" column_name="component" 
| search component!="_*"

Please try out and confirm!

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

Nadhiyaa
Path Finder

@niketnilay When i try the bars are not in the descendingly sorted . How to fix that

0 Karma

niketn
Legend

@Nadhiyaa what is the query you are using. The top command in the above example applies reverse sorting based on volume for a field. So this is supposed to work. Did you try out the run anywhere example based on Splunk's _internal index?

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

Nadhiyaa
Path Finder

@niketnilay yes the color changes but the visualization doesn't look from top to bottom .

0 Karma

niketn
Legend

For me a Column or Bar chart works fine not sure which visualization you are using and what is your query. I have changed the query to stats to see if this is what you are using.

index=_internal sourcetype=splunkd
| stats count by log_level 
| eventstats sum(count) as totalCount 
| eval percentage=round((count/totalCount)*100,3) 
| fields - count totalCount 
| chart max(percentage) as "Percentage (max)" by log_level
| sort 0 - "Percentage (max)"
| transpose 0 header_field=log_level column_name=log_level

If this does not work kindly post the query you are using as a new question!

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

ramki1459
Explorer

thank you so much. it worked 🙂

0 Karma

somesoni2
Revered Legend

Give this a try

|query
 | stats count by app_status| eventstats sum(count) as totalCount 
 | eval percentage=round((count/totalCount)*100,3)
 | fields - count totalCount | eval temp=app_status
 | chart max(percentage) by t app_status temp
0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...