这个查询给了我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)]
如何获得指标/分钟?
度量的单位是"1"
(就像大多数反度量一样)。速率校准器的结果总是以每秒为单位。所以校准器输出的单位是"1/s"
。MQL有一个scale
[可用于缩放值的函数。在这种情况下,在对齐步骤之后添加| value scale(val(), "1/min")
可以将其缩放为具有"1/min"的单位。(简写就是| scale "1/min"
)
另一种变化是将"1"
替换为正在计数的事物的注释:' "{请求}/分钟"。单位按UCUM单位标准
给出则查询为
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
最终样式注释:within
给出了查询输出的范围(即使最后没有给出)。把它放在最后是个好主意。