异常值

利用 Google Play Developer Reporting API,您可以检索在指标集中检测到的异常。每当该指标值超过指标的预期范围时,系统就会根据该指标在过去 28 天内的值生成异常值。连续几天的异常情况会合并为一个异常结果。

如果指标值的异常增加持续足够长的时间,检测模型会调整并扩大预期值,直到后续数据点不再被视为异常。

检索异常值

异常可以使用 anomalies.list 方法列出。

简单请求:

此 HTTP GET 请求会指定应用名称参数,并返回您的应用检测到的异常的完整列表。

GET https://playdeveloperreporting.googleapis.com/v1beta1/apps/com.example.app/anomalies

异常响应:

响应包含的信息足以查询异常情况的确切发生位置:

{
 
"anomalies": [
   
{
     
"name": "apps/com.example.app/anomalies/12345"
     
"metric_set": "apps/com.example.app/anrRateMetricSet"
     
"timeline_spec": {
       
"aggregation_period": "DAILY"
       
"start_time": {
         
"year": 2022
         
"month": 1
         
"day": 23
         
"time_zone": {
           
"id": "America/Los_Angeles"
         
}
       
}
       
"end_time": {
         
"year": 2022
         
"month": 1
         
"day": 23
         
"time_zone": {
           
"id": "America/Los_Angeles"
         
}
       
}
     
}
     
"metric": {
       
"metric": "anrRate",
       
"decimal_value": {
         
"value": "3.1415926535"
       
}
     
}
   
},
   
{
     
"name": "apps/com.example.app/anomalies/12345"
     
"metric_set": "apps/com.example.app/crashRateMetricSet"
     
"timeline_spec": {
       
"aggregation_period": "DAILY"
       
"start_time": {
         
"year": 2021
         
"month": 12
         
"day": 10
         
"time_zone": {
           
"id": "America/Los_Angeles"
         
}
       
}
       
"end_time": {
         
"year": 2021
         
"month": 12
         
"day": 10
         
"time_zone": {
           
"id": "America/Los_Angeles"
         
}
       
}
     
}
     
"metric": {
       
"metric": "crashRate",
       
"decimal_value": {
         
"value": "2.7182818284"
       
}
     
}
   
},
 
]
}

过滤的请求:

您可以应用过滤条件,以仅返回在特定时间段内处于活跃状态的异常值。为此,请在请求的过滤器字段中指定 activeBetween(start, end) 函数。您可以使用特殊关键字 UNBOUNDED 在范围的任意一侧指定无限制限制。如果指定开始或结束边界,则必须遵循 RFC 3339 格式,例如 2022-02-22T04:00Z

GET https://playdeveloperreporting.googleapis.com/v1beta1/apps/com.example.app/anomalies?filter=activeBetween("2022-01-01T00:00:00Z", UNBOUNDED)

过滤的响应:

响应仅包含指定时间范围内发生的异常:

{
 
"anomalies": [
   
{
     
"name": "apps/com.example.app/anomalies/12345"
     
"metric_set": "apps/com.example.app/anrRateMetricSet"
     
"timeline_spec": {
       
"aggregation_period": "DAILY"
       
"start_time": {
         
"year": 2022
         
"month": 1
         
"day": 23
         
"time_zone": {
           
"id": "America/Los_Angeles"
         
}
       
}
       
"end_time": {
         
"year": 2022
         
"month": 1
         
"day": 23
         
"time_zone": {
           
"id": "America/Los_Angeles"
         
}
       
}
     
}
     
"metric": {
       
"metric": "anrRate",
       
"decimal_value": {
         
"value": "3.1415926535"
       
}
     
}
   
},
 
]
}

可用指标

目前,并非所有指标和指标集都支持异常值检测。下面列出了当前支持的指标:

指标集 支持的指标
vitals.anrrate anrRate
vitals.crashrate crashRate
vitals.excessivewakeuprate 过多 WakeupRate
vitals.stuckbackgroundwakelockrate 卡住了 BakeWakelockRate