This query gives me metrics/sec:
fetch https_lb_rule::loadbalancing.googleapis.com/https/request_count
| within 5m
| align rate(1m)
| every 1m
| group_by
[ metric.cache_result,metric.proxy_continent,metric.response_code_class,metric.response_code,metric.protocol,resource.backend_name,resource.backend_type,resource.backend_scope,resource.backend_scope_type,resource.backend_target_type,resource.backend_target_name,resource.forwarding_rule_name,resource.matched_url_path_rule,resource.target_proxy_name,resource.url_map_name,resource.region,resource.project_id ],
[value_request_count_aggregate: aggregate(value.request_count)]
How to get metrics/minute?
The units for the metric are "1"
(as they are for most counter metrics). The rate aligner result are always per-second. So the output of the aligner has units "1/s"
. MQL has a scale
[
function that can be used to scale a value. In this case, adding | value scale(val(), "1/min")
after the align step can be used to scale this to have units "1/min". (A shortcut way of saying that is | scale "1/min"
)
A variation on this is to replace the "1"
with an annotation of the thing being counted: `"{requests}/min". The units are given according to the UCUM units standard
The query is then
fetch https_lb_rule::loadbalancing.googleapis.com/https/request_count
| align rate(1m)
| scale "{requests}/min"
| every 1m
| group_by
[metric.cache_result,metric.proxy_continent,
metric.response_code_class,metric.response_code,
metric.protocol,resource.backend_name,
resource.backend_type,resource.backend_scope,
resource.backend_scope_type, resource.backend_target_type,
resource.backend_target_name, resource.forwarding_rule_name,
resource.matched_url_path_rule,
resource.target_proxy_name, resource.url_map_name,
resource.region,resource.project_id ],
[value_request_count_aggregate:
aggregate(val(0))]
| div 60
| within 5m
Final style note: within
gives the range of the output of the query (even if it isn't given at the end). Putting it at the end is a good idea.