Dynamic Bar Color Based on Comparison Between Two Fields (Cost vs Budget) in Grafana

I’m working on a cost visualization dashboard for multiple AWS accounts. Each account has a daily cost and a fixed budget_limit. My goal is to visualize the daily cost for each account and highlight the bar in red if the cost exceeds the budget limit.

Here’s my setup:

  • I have a MySQL table with columns: account_name, cost, budget_limit, date.
  • Each account has a different budget limit and the costs are updated daily.
  • I want to color the bars conditionally based on whether cost exceeds budget_limit (i.e., red if cost > budget_limit, green otherwise).

image