Cloudwatch使用问题:如何在查询中正确使用percentile百分位统计功能?
CloudWatch 百分位功能说明
CloudWatch 完全支持百分位统计能力,你遇到的报错是函数拼写错误导致的:你写的precentile是错误拼写,正确的函数名是percentile。
正确使用方式
你要获取指标someValue的p90值,正确的CloudWatch Logs Insights查询语句为:
| stats percentile(someValue, 90) as p90_someValue
扩展常用场景
- 同时统计多个百分位数值,比如同步获取p50、p95、p99:
| stats percentile(someValue, 50) as p50, percentile(someValue, 95) as p95, percentile(someValue, 99) as p99
- 搭配分组规则统计不同维度的百分位,比如按接口路径分组统计各接口的p90响应耗时:
| stats percentile(request_time, 90) as p90_time by request_path
如果你是直接查询CloudWatch原生指标而非日志,在控制台或者API调用时,直接选择统计方式为p+对应百分位数值即可,比如选择p90作为统计函数就能得到该指标的90百分位值。
内容的提问来源于stack exchange,提问作者Gambit2007
相关产品推荐
相关产品推荐

