Expression where some values might be "no data"

  • What Grafana version and what operating system are you using?
    Grafana v10.1.1
    Ubuntu 22.04

  • What are you trying to achieve?
    I am trying to add a ‘Stat’ visualization which sums stats from a handful of measurements, some of which may have no data for a given requestId (see below).

  • How are you trying to achieve it?

I have the following measurements: m1, m2, m3, m4, m5
Each measurement has a field “execTime”
Each measurement has a tag “requestId”

For the visualization I have 5 different queries
SELECT "execTime" FROM <measurement> WHERE requestId = ${requestId}

Finally I have an expression that adds all the results together
Operation: Math
Expression: $A + $B + $C + $D + $E

  • What happened?
    My stat displays “No Data”

  • What did you expect to happen?
    It would display the sum of all the queries, excluding any that return “No Data”

  • Can you copy/paste the configuration(s) that you are having problems with?
    I don’t think that is neccessary here, but maybe, if needed

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    No errors, just odd behavior

  • Did you follow any online instructions? If so, what is the URL?

Are those queried as timeseries? Because if they are timeseries, then it is not so simple:

They are, but I tried table as well as logs and neither worked.

I’m not married to using an expression. I simply want to add “execTime” from these 5 different tables. What is the recommended way to accomplish that?

I would try to use that Influx SQL. Not real Influx SQL, just idea:

SELECT SUM("execTime") AS execTime
FROM <measurement> 
WHERE requestId IN ( requestId1, requestId2, requestId3, ...)

Right, but how do I add the result of these 5 queries together?

Again noting that some of these queries may result in “No Data” (which we should just treat as 0)

I think you don’t understand my query example - one query selects X different request ids and calculate their SUM on the SQL level - there is no need of X queries (and other Grafana related problems, e.g. “how do I add the result of these 5 queries together”).