You can call this operation to query the metrics of Browser Monitoring.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Description

You can call QueryMetric to query the metrics of Application Monitoring and Browser Monitoring. This topic describes how to query the metrics of Browser Monitoring.

Operation Request Response
QueryMetric QueryMetricRequest QueryMetricResponse

Request parameters

Request parameters include common parameters and operation-specific parameters.

Common request parameters

For more information about common request parameters, see Common parameters.

Operation-specific parameters

Alibaba Cloud encapsulates all request parameters in a request, and returns a response.

Parameter Type Setting method Description Required Remarks
startTime Long setStartTime The beginning of the time range to query. Yes N/A
endTime Long setEndTime The end of the time range to query. Yes N/A
metric String setMetric The metric to be queried. Yes N/A
measures List[String] setMesures The measurement data of the metric. Yes N/A
dimensions List[String] setDimensionss The dimension by which the data is queried. No N/A
filters List[Filter] setFilters The filtering condition for the query. Yes N/A
intervalInSec Integer setIntervalInSec The time interval between the data shards to be queried. No N/A
orderBy String setOrderBy The basis of sorting. No N/A
limit Integer setLimit The limit to the number of returned results. No N/A
order String setOrder Specifies whether the data is sorted in ascending or descending order. No ASC specifies ascending order, whereas DESC specifies descending order.
securityToken String setSecurityToken The security token generated by Security Token Service (STS) for the Resource Access Management (RAM) role. No You must set this parameter if you use a RAM role.

Fields in filters

Parameter Type Setting method Description Example
key String setKey The name of the dimension. appId
value String setValue The dimension value. 11
Notice To query any metric of Application Monitoring, you must add pid in filters.

How to obtain the pid of an application

In the left-side navigation pane, click Browser Monitoring. On the Browser Monitoringpage, click the name of the target application to go to the overview page of this application.

The URL in the browser address bar contains the pid of this application in the format of pid=xxx. The browser is encoded, and therefore you need to modify the pid of all applications except for those in in Enterprise Distributed Application Service (EDAS). For example, if the pid in the URL is xxx%4074xxx, you need to replace %40 with @. That is, the pid is modified to xxx@74xxx.

Response parameters

Response data is returned as JSON strings. You can run QueryMetricResponse.getdata() to query the response data.

Parameter Description Remarks
data The data point returned. N/A

Queryable Browser Monitoring metrics

You can call the QueryMetric operation to query the following metrics of Browser Monitoring.

Note If you know the specific query conditions, add the value to the filters parameter to restrict the range of query results. If you do not know the specific query conditions, pass the dimensions in the following table to the dimensions parameter to obtain a list of all possible values of the dimension. For example, if you know the ip_country_id of a country, but do not know the ip_region_id of each region of this country, you can pass ip_country_id to the filters parameter and pass ip_region_id to the dimensions parameter. In this way, you can obtain the ip_region_id of every region of this country and can then use the specific ip_region_id to make a more precise query.
Metric Description Dimension Measurement data
webstat.session Session tracing N/A
  • page
  • sid
  • browser
  • load
  • date
  • browser_version
webstat.index Overview
  • ip_country_id
  • ip_region_id
  • detector_browser
  • detector_device
  • detector_os
  • sr (screen resolution)
  • pv
  • uv
webstat.satisfy Satisfaction
  • page
  • ip_country_id
  • Ip_region_id
  • detector_browser
  • detector_device
  • detector_os
  • sr
  • satisfy
webstat.url Access URL
  • page
  • ip_country_id
  • ip_region_id
  • detector_browser
  • detector_device
  • detector_os
  • sr
  • pv
  • uv
webstat.speed Page speed
  • page
  • ip_country_id
  • ip_region_id
  • detector_browser
  • detector_device
  • detector_os
  • sr
  • avg_fpt
  • avg_ready
  • avg_load
  • avg_dns
  • avg_tcp
  • avg_ssl
  • avg_ttfb
  • avg_trans
  • avg_dom
  • avg_res
  • avg_tti
webstat.stable Error rate ranking
  • page
  • ip_country_id
  • ip_region_id
  • detector_browser
  • detector_device
  • detector_os
  • sr
  • rate
  • pv
webstat.errcate Error message ranking
  • msg
  • ip_country_id
  • ip_region_id
  • detector_browser
  • detector_device
  • detector_os
  • sr
  • count
webstat.api API call success rate
  • api
  • ip_country_id
  • ip_region_id
  • detector_browser
  • detector_device
  • detector_os
  • sr
  • rate
  • pv
webstat.apimsg API message clustering
  • msg
  • ip_country_id
  • ip_region_id
  • detector_browser
  • detector_device
  • detector_os
  • sr
  • count
webstat.apicost Response time for successful API calls
  • api
  • ip_country_id
  • ip_region_id
  • detector_browser
  • detector_device
  • detector_os
  • sr
  • count
  • avg_time
webstat.apifailtime Response time for failed API calls
  • api
  • ip_country_id
  • ip_region_id
  • detector_browser
  • detector_device
  • detector_os
  • sr
  • count
  • avg_time
webstat.sum Custom statistics: sum
  • key
  • ip_country_id
  • ip_region_id
  • detector_browser
  • detector_device
  • detector_os
  • sr
  • sum_val
  • count
  • uv
webstat.avg Custom statistics: average
  • key
  • ip_country_id
  • ip_region_id
  • detector_browser
  • detector_device
  • detector_os
  • sr
  • avg_val
  • count

Sample code

The following is the sample code for calling the QueryMetric operation to query the page view (PV) and the unique visitor (UV) on the Overview page of Browser Monitoring:

  1. import com.aliyuncs.DefaultAcsClient;
  2. import com.aliyuncs.IAcsClient;
  3. import com.aliyuncs.exceptions.ClientException;
  4. import com.aliyuncs.exceptions.ServerException;
  5. import com.aliyuncs.profile.DefaultProfile;
  6. import com.google.gson.Gson;
  7. import java.util.*;
  8. import com.aliyuncs.arms.model.v20190808.*;
  9. public class ARMSDemo {
  10. public static void main(String[] args) {
  11. DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", "<accessKeyId>", "<accessKeySecret>");
  12. IAcsClient client = new DefaultAcsClient(profile);
  13. QueryMetricRequest request = new QueryMetricRequest();
  14. request.setEndTime(1555488869888);
  15. request.setStartTime(1555482869888);
  16. request.setMetric("webstat.index");
  17. List<String> measuresList = new ArrayList<String>();
  18. measuresList.add("pv");
  19. measuresList.add("uv");
  20. request.setMeasuress(measuresList);
  21. List<QueryMetricRequest.Filters> filtersList = new ArrayList<QueryMetricRequest.Filters>();
  22. QueryMetricRequest.Filters filters1 = new QueryMetricRequest.Filters();
  23. filters1.setKey("pid");
  24. filters1.setValue("xxx");
  25. filtersList.add(filters1);
  26. QueryMetricRequest.Filters filters2 = new QueryMetricRequest.Filters();
  27. filters2.setKey("regionId");
  28. filters2.setValue("cn-hangzhou");
  29. filtersList.add(filters2);
  30. request.setFilterss(filtersList);
  31. try {
  32. QueryMetricResponse response = client.getAcsResponse(request);
  33. System.out.println(new Gson().toJson(response));
  34. } catch (ServerException e) {
  35. e.printStackTrace();
  36. } catch (ClientException e) {
  37. System.out.println("ErrCode:" + e.getErrCode());
  38. System.out.println("ErrMsg:" + e.getErrMsg());
  39. System.out.println("RequestId:" + e.getRequestId());
  40. }
  41. }
  42. }
  1. const Core = require('@alicloud/pop-core');
  2. var client = new Core({
  3. accessKeyId: '<accessKeyId>',
  4. accessKeySecret: '<accessKeySecret>',
  5. endpoint: 'http://arms.cn-hangzhou.aliyuncs.com',
  6. apiVersion: '2019-08-08'
  7. });
  8. var params = {
  9. "Measures.1": "pv",
  10. "Measures.2": "uv",
  11. "Filters.1.Key": "pid",
  12. "Filters.1.Value": "xxx",
  13. "Filters.2.Key": "regionId",
  14. "Filters.2.Value": "cn-hangzhou",
  15. "Metric": "webstat.index",
  16. "StartTime": 1555482869888,
  17. "EndTime": 1555488869888
  18. }
  19. var requestOption = {
  20. method: 'POST'
  21. };
  22. client.request('QueryMetric', params, requestOption).then((result) => {
  23. console.log(result);
  24. }, (ex) => {
  25. console.log(ex);
  26. })
  1. package main
  2. import (
  3. "fmt"
  4. "github.com/aliyun/alibaba-cloud-sdk-go/services/arms"
  5. )
  6. func main() {
  7. client, err := arms.NewClientWithAccessKey("cn-hangzhou", "<accessKeyId>", "<accessKeySecret>")
  8. request := arms.CreateQueryMetricRequest()
  9. request.EndTime = "1555488869888"
  10. request.StartTime = "1555482869888"
  11. request.Metric = "webstat.index"
  12. request.Measures = &[]string{"pv", "uv"}
  13. request.Filters = &[]arms.QueryMetricFilters{
  14. {
  15. Key: "pid",
  16. Value: "xxx",
  17. },
  18. {
  19. Key: "regionId",
  20. Value: "cn-hangzhou",
  21. },
  22. }
  23. response, err := client.QueryMetric(request)
  24. if err ! = nil {
  25. fmt.Print(err.Error())
  26. }
  27. fmt.Printf("response is %#v\n", response)
  28. }
  1. <? php
  2. use AlibabaCloud\Client\AlibabaCloud;
  3. use AlibabaCloud\Client\Exception\ClientException;
  4. use AlibabaCloud\Client\Exception\ServerException;
  5. // Download:https://github.com/aliyun/openapi-sdk-php-client
  6. // Usage:https://github.com/aliyun/openapi-sdk-php-client/blob/master/README-CN.md
  7. AlibabaCloud::accessKeyClient('<accessKeyId>', '<accessKeySecret>')
  8. ->regionId('cn-hangzhou') // replace regionId as you need
  9. ->asGlobalClient();
  10. try {
  11. $result = AlibabaCloud::rpcRequest()
  12. ->product('ARMS')
  13. // ->scheme('https') // https | http
  14. ->version('2019-08-08')
  15. ->action('QueryMetric')
  16. ->method('POST')
  17. ->options([
  18. 'query' => [
  19. 'Measures.1' => 'pv',
  20. 'Measures.2' => 'uv',
  21. 'Filters.1.Key' => 'pid',
  22. 'Filters.1.Value' => 'xxx',
  23. 'Filters.2.Key' => 'regionId',
  24. 'Filters.2.Value' => 'cn-hangzhou',
  25. 'Metric' => 'webstat.index',
  26. 'StartTime' => '1555482869888',
  27. 'EndTime' => '1555488869888',
  28. ],
  29. ])
  30. ->request();
  31. print_r($result->toArray());
  32. } catch (ClientException $e) {
  33. echo $e->getErrorMessage() . PHP_EOL;
  34. } catch (ServerException $e) {
  35. echo $e->getErrorMessage() . PHP_EOL;
  36. }
  1. #! /usr/bin/env python
  2. #coding=utf-8
  3. from aliyunsdkcore.client import AcsClient
  4. from aliyunsdkcore.acs_exception.exceptions import ClientException
  5. from aliyunsdkcore.acs_exception.exceptions import ServerException
  6. from aliyunsdkarms.request.v20190808.QueryMetricRequest import QueryMetricRequest
  7. client = AcsClient('<accessKeyId>', '<accessKeySecret>', 'cn-hangzhou')
  8. request = QueryMetricRequest()
  9. request.set_accept_format('json')
  10. request.set_EndTime(1555488869888)
  11. request.set_StartTime(1555482869888)
  12. request.set_Metric("webstat.index")
  13. request.set_Measuress(["pv","uv"])
  14. request.set_Filterss([
  15. {
  16. "Key": "pid",
  17. "Value": "xxx"
  18. },
  19. {
  20. "Key": "regionId",
  21. "Value": "cn-hangzhou"
  22. }
  23. ])
  24. response = client.do_action_with_exception(request)
  25. # python2: print(response)
  26. print(str(response, encoding='utf-8'))
  1. using System;
  2. using System.Collections.Generic;
  3. using Aliyun.Acs.Core;
  4. using Aliyun.Acs.Core.Exceptions;
  5. using Aliyun.Acs.Core.Profile;
  6. using Aliyun.Acs.ARMS.Model.V20190808;
  7. namespace ARMSDemo
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. IClientProfile profile = DefaultProfile.GetProfile("cn-hangzhou", "<accessKeyId>", "<accessKeySecret>");
  14. DefaultAcsClient client = new DefaultAcsClient(profile);
  15. var request = new QueryMetricRequest();
  16. request.EndTime = 1555488869888;
  17. request.StartTime = 1555482869888;
  18. request.Metric = "webstat.index";
  19. var measuresList = new List<String>();
  20. measuresList.Add("pv");
  21. measuresList.Add("uv");
  22. request.Measuress = measuresList;
  23. var filtersList = new List<QueryMetricRequest.Filters>();
  24. var filters1 = new QueryMetricRequest.Filters();
  25. filters1.Key = "pid";
  26. filters1.Value = "xxx";
  27. filtersList.Add(filters1);
  28. var filters2 = new QueryMetricRequest.Filters();
  29. filters2.Key = "regionId";
  30. filters2.Value = "cn-hangzhou";
  31. filtersList.Add(filters2);
  32. request.Filterss = filtersList;
  33. try {
  34. var response = client.GetAcsResponse(request);
  35. Console.WriteLine(System.Text.Encoding.Default.GetString(response.HttpResponse.Content));
  36. }
  37. catch (ServerException e)
  38. {
  39. Console.WriteLine(e);
  40. }
  41. catch (ClientException e)
  42. {
  43. Console.WriteLine(e);
  44. }
  45. }
  46. }
  47. }
  1. # gem install aliyunsdkcore
  2. require 'aliyunsdkcore'
  3. client = RPCClient.new(
  4. access_key_id: '<accessKeyId>',
  5. access_key_secret: '<accessKeySecret>',
  6. endpoint: 'https://arms.aliyuncs.com',
  7. api_version: '2019-08-08'
  8. )
  9. response = client.request(
  10. action: 'QueryMetric',
  11. params: {
  12. "Measures.1": "pv",
  13. "Measures.2": "uv",
  14. "Filters.1.Key": "pid",
  15. "Filters.1.Value": "xxx",
  16. "Filters.2.Key": "regionId",
  17. "Filters.2.Value": "cn-hangzhou",
  18. "Metric": "webstat.index",
  19. "StartTime": 1555482869888,
  20. "EndTime": 1555488869888
  21. },
  22. opts: {
  23. method: 'POST'
  24. }
  25. )
  26. print JSON.parse(response.body)