Having difficulty with subqueries

Okay, not the greatest title, but hopefully it covers enough. I will try to explain as best I can…

I have data going to InfluxDB that tracks how long that a specific action takes to respond and I want to add a Grafana chart that shows me the percent of actions that take over 1000ms but I’m struggling to figure that out.

InfluxDb Structure :

  • time = the time the request was made
  • last = the amount of time in ms the request took.

So for example, the following would chart the time each request took…

SELECT ("last") FROM "metrics"."autogen"."application_timer" WHERE time > :dashboardTime: AND time < :upperDashboardTime: FILL(null)

What I want though, is to track the percentage of requests that take over 1000ms. I’m extremely unfamiliar with Influx/Grafana so my pseduo code looks something like this…

select ((select count(last) > 1000) / (select count(last)) FROM "metrics"."autogen"."application_timer" WHERE time > :dashboardTime: AND time < :upperDashboardTime: FILL(null)

Could someone push me in the right direction with this? I’m sure its something simple, but I’ve read through a handful of tutorials on the internet and just can’t seem to get my query right.

Thank you!