How to handle multiple query in Grafana panel?

I am creating a panel with multiple Query expressions in Grafana and my panel has Query from A to H.

I need to execute these queries in If…else structure.

If A to G queries doesn’t provide any data then only H needs to be executed. How could I achieve this?

Any help at all would be a great help!

Hi @roopchandcse,

Thanks for opening this post.

Did you already check the documentation regarding it i.e.

Hi @usman.ahmad,

Thanks for your reply. I just checked the documentation you shared but this is not my case

Let me explain my issue in detail,

I need to grep some keywords in logs (LOKI) and if the keywords are present during that interval then I’ll consider it as Fail(Red) or else Pass(Green).

I am using StatusMap for this and my panel has queries from A to H,

A to G have error scenarios. If A to G fails then the H query needs to be executed so that I’ll show it in Green with a tooltip message as Pass.

A → count by (hostname,location)(count_over_time({component=“cp-snmp”,cloud=~“${cloud}”,environment=~“${environment}”, location=~“${location}”} |= “connection to CS is lost”[$__interval]) > 0) + 5
B → count by (hostname,location)(count_over_time({component=“cp-snmp”,cloud=~“${cloud}”,environment=~“${environment}”, location=~“${location}”} |= “Error”[$__interval]) > 10) + 10
C → count by (hostname,location)(count_over_time({component=“cp-snmp”,cloud=~“${cloud}”,environment=~“${environment}”, location=~“${location}”} |= “Failed”[$__interval]) > 10) + 15
.
.
.
.
H → count by(hostname,location)(topk(10,count_over_time({component=“cp-snmp”,cloud=~“${cloud}”,environment=~“${environment}”, location=~“${location}”} [$__interval])))

Hi @roopchandcse,

So I talked with the team and unfortunately, Grafana does not have that feature i.e. conditionally running a query in like a IF => THEN style fashion.

Best will be to request this feature at our Github requests and try to explain your scope which much detail as possible so that the developer can have good information.