Change Panel colour based on Multiple Queries

  • What Grafana version and what operating system are you using?
    v8.5.0 is grafana version and it is deployed as a container

  • What are you trying to achieve?
    I am trying to create a panel for displaying service health status. Where colour of panel should change like Green to denote healthy, Orange to denote Warning and Red to denote critical

  • How are you trying to achieve it?
    I am using alertmanager as datasource to query based on tags like severity=“critical”

  • What happened?
    Now issue is, I am looking for a way to change my panel colour based on sub-queries instead of any threshold.
    Query A - to list all alerts where severity is critical
    Query B - to list all alerts where severity is warning
    Now on Query C I am thinking to add some conditional expression to determine if we have any critical count or warning count so that accordingly I can change the colour of panel.
    What should be the best approach in such scenarios ?

Welcome @pritamdsgpta

Have you seen this post? It seems this might be a good starting point.

Is there any reason you separate the querie what is your data source?
If they must be separate maybe youcan merge them via transformation so that you could use value mapping on the merged result

@yosiasz - My datasource is alertmanager

1 Like

Thanks @grant2, let me check and try out.

Not able to achieve what I am expecting.
I want to change colour based on below conditions:

Query A(critical) Query B (warning) Panel Colour
Exist Not Exist Red
Exist Exist Red
Not Exist Exist Orange
Not Exist Not Exist Green