edit-icon download-icon

Universal dataset query APIs

Last Updated: Apr 11, 2018

Description

ARMSQueryDataSet queries the data in ARMS datasets.

API name Request Response
ARMSQueryDataSet ARMSQueryDataSetRequest ARMSQueryDataSetResponse

Request parameters

Request parameters include POP public parameters and business parameters. For public request parameters, see POP parameter description.

Business parameter description

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

ARMSQueryDataSetRequest contains 11 fields.

Field name Field type Setting method Field description Required/Optional Note
datasetId Long setDatasetId Dataset ID Required
minTime Long setMinTime Start time of data query Required
maxTime Long setMaxTime End time of data query Required
intervalInSec Integer setIntervalInSec Interval of data piece Required
measures List[String] setMesures Query measure list Optional The list can contain up to three elements. If the parameter is left unspecified, all measures are returned.
dimensions List[Dimension] setDimensions Query dimension list Optional Drill-down dataset field. “dimensions” is a compound parameter. The list can have contain up to three elements. For the definition of the dimension, see the next table.
requiredDims List[Dimension] setRequiredDims Required dimensions of a common dataset Optional Common dataset field
optionalDims List[Dimension] setOptionalDims Optional dimensions of a common dataset Optional Common dataset field
orderByKey String setOrderByKey orderBy measure Optional
limit Integer setLimit The limit to the number of returned results Optional
reduceTail Boolean setReduceTail If to aggregate all data beyond the limit Optional
  • If the dataset to be queried is a drill-down dataset, use “dimensions”.
  • If the dataset to be queried is a common dataset, use “requiredDims” and “optionalDims”.
  • For differences between a drill-down dataset and a common dataset, see Create a dataset.

Description of the “dimensions” compound parameter

Field name Field type Setting method Field description Note
key String setKey Dimension name For example, region
value String setValue Dimension value For example, Beijing
type String setType Value type Options include STATIC, ALL, and DISABLED.
  • To select all values under a dimension, set “type” to “All” and “value” to “null”.
  • To select a specific value under a dimension, set “type” to “STATIC” and “value” to the entered dimension value.
  • If you don’t want to select a dimension, ignore this dimension, or set “type” to “DISABLED”.

Response parameters

Response parameters are returned as JSON strings. You can retrieve response values with ARMSQueryDataSetResponse.getdata().

ARMSQueryDataSetRequest contains the following fields:

Field name Field description Note
dimensions Dimension value of the time series data If this field is set to “ALL”, multiple dimensions are available.
measures Measures in the data point
resultSize Number of all data points returned
dimData Multiple time series data records

Examples

  1. If no dimension is selected, summary information of all data is queried.

    1. import java.util.ArrayList;
    2. import java.util.List;
    3. import com.aliyuncs.DefaultAcsClient;
    4. import com.aliyuncs.IAcsClient;
    5. import com.aliyuncs.arms.model.v20161125.ARMSQueryDataSetRequest;
    6. import com.aliyuncs.arms.model.v20161125.ARMSQueryDataSetRequest.Dimensions;
    7. import com.aliyuncs.arms.model.v20161125.ARMSQueryDataSetResponse;
    8. import com.aliyuncs.exceptions.ClientException;
    9. import com.aliyuncs.profile.DefaultProfile;
    10. import com.aliyuncs.profile.IClientProfile;
    11. public class ARMSGeneralQuery {
    12. public static void main(String[] args) throws ClientException {
    13. // AccessKey of your primary account, which can be viewed and obtained in the Alibaba Cloud console
    14. String accessKeyId = "xxx";
    15. // SecretKey of your primary account, which can be viewed and obtained in the Alibaba Cloud console
    16. String accessKeySecret = "xxx";
    17. //The region must be consistent with the endpoint. The content is subject to the region of ARMS.
    18. //Currently, "cn-hangzhou" and "cn-beijing" are supported. The specific value is determined by the region of the ARMS console.
    19. String endpoint = "cn-hangzhou";
    20. String region = "cn-hangzhou";
    21. //Always set the product name to "ARMS".
    22. String productName = "ARMS";
    23. //If the region is not Hangzhou, change the region in the string domain, for example, to cn-beijing.
    24. String domain = "arms.cn-hangzhou.aliyuncs.com";
    25. IClientProfile profile = DefaultProfile.getProfile(region, accessKeyId, accessKeySecret);
    26. DefaultProfile.addEndpoint(endpoint, region, productName, domain);
    27. //Set business parameters
    28. ARMSQueryDataSetRequest armsQueryDataSetRequest = new ARMSQueryDataSetRequest();
    29. //DatasetID can be queried on the dataset management page.
    30. armsQueryDataSetRequest.setDatasetId(1340l);
    31. //Interval for returning the query data. The value must be a multiple of 60.
    32. armsQueryDataSetRequest.setIntervalInSec(60);
    33. //Set the query start time and end time. In this example, data in the last 10 minutes is queried. Note that the unit is ms.
    34. armsQueryDataSetRequest.setMinTime(System.currentTimeMillis() - 600000);
    35. armsQueryDataSetRequest.setMaxTime(System.currentTimeMillis());
    36. // ****Insert the code of Example 2, 3, and 4 here.****
    37. IAcsClient client = new DefaultAcsClient(profile);
    38. try {
    39. //Send the request.
    40. ARMSQueryDataSetResponse armsQueryDataSetResponse = client.getAcsResponse(armsQueryDataSetRequest);
    41. //Retrieve and print the response.
    42. System.out.println(armsQueryDataSetResponse.getData());
    43. } catch (ClientException e) {
    44. e.printStackTrace();
    45. }
    46. }
    47. }
  2. Select the first dimension, and set the dimension value to an empty string (“”) and the dimension type to “ALL”. The data grouped by the first dimension is returned.

    1. Dimensions dimensions = new Dimensions();
    2. dimensions.setKey(“Region");
    3. dimensions.setValue("");
    4. dimensions.setType("ALL");
    5. List<Dimensions> dimensionss = new ArrayList<Dimensions>();
    6. dimensionss.add(dimensions);
    7. armsQueryDataSetRequest.setDimensionss(dimensionss);
  3. Select the first dimension, and set the dimension value to a fixed value, for example “hangzhou”, and set the dimension type to “STATIC” (fixed value). The data of hangzhou is returned based on the first dimension:

    1. Dimensions dimensions = new Dimensions();
    2. dimensions.setKey("Region");
    3. dimensions.setValue("hangzhou");
    4. dimensions.setType("STATIC");
    5. List<Dimensions> dimensionss = new ArrayList<Dimensions>();
    6. dimensionss.add(dimensions);
    7. armsQueryDataSetRequest.setDimensionss(dimensionss);
  4. Select the measure list to be queried. Only the specified measures are returned.

    1. List<String> measuress = new ArrayList<String>();
    2. measuress.add("Price");
    3. measuress.add("Quantity");
    4. armsQueryDataSetRequest.setMeasuress(measuress);
Thank you! We've received your feedback.