I’m trying to calculate availability percentage of a web site. I thought of dividing (number of 200 codes) by (number of total response).
So, here are my 2 influxql queries:
SELECT count("http_response_code") AS "up" FROM "http_response" WHERE ("name" =~ /^$name$/ AND "status_code" = '200') AND $timeFilter GROUP BY time(5m), "name" fill(null)
SELECT count("http_response_code") AS "total" FROM "http_response" WHERE ("name" =~ /^$name$/) AND $timeFilter GROUP BY time(5m), "name" fill(null)
Second one is the same with first one only without “200” filter. As far as I know I can’t divide these 2 using influxql. Can you show me an example of how to get this percentage using Flux or any other way if you have better ideas.
So, I’ve created this flux code but I’ve a problem. It returns 3 tables and displays all values from “success”, “total” and “result”. Yet, I want to display only the “result” table. How can I drop first tables?
@Mert The yield() calls are what are forcing the other tables into the output. If yield() is called anywhere in your script, the output of that yield is included in the final output of the script. You don’t need the yields on each.
One other way to do this would be to extract the total requests as a scalar value. That way you don’t have to do a join and the query will likely be much more performant: