百度智能云

All Product Document

          Cloud Monitor

          Query Data API

          API description

          Retrieve Time Series data for one or more statistics based on specified Metrics, including Cloud Product Monitor data, Site Monitor data, or Custom Monitor data that you have uploaded.

          API restriction

          The number of DataPoints returned in a single response cannot exceed 1,440.

          Request parameters

          Name Types Description Required or not Parameter location
          userId String Tenant ID Yes URL parameter
          scope String, limited to the following character set: 0~9, A~Z, a~z, _ Scope Yes URL parameter
          metricName String, limited to the following character set: 0~9, A~Z, a~z, _ Monitor Metric name Yes URL parameter
          statistics Statistics, in statistics1, statistics2, statistics3 format, options: average, maximum, minimum, sum, sampleCount Statistic Method Type Yes Query
          dimensions A string formatted as dimensionName:dimensionValue. For Metrics with multiple Dimensions, connect them using semicolons, e.g., dimensionName:dimensionValue;dimensionName:dimensionValue. Each dimension can have only one specified value. Dimension list Yes Query
          startTime DateTime, refer to Date and Time, expressed in UTC date Query start time Yes Query
          endTime DateTime, refer to Date and Time, expressed in UTC date Query end time Yes Query
          periodInSecond Integer, multiple of 60, unit: second (s) Statistical Period Yes Query

          Parameter explanation

          • For concepts like Scope, Metric, Statistic, and Dimension, refer to [Core Concepts](BCM/Product Description/Core concepts.md).

          Response parameters

          Name Types Description
          requestId String Request identifier
          code String Return code
          message String Error message
          dataPoints List(DataPoint) Monitor Metric

          DataPoint

          Name Types Description
          average double Average of Metrics within the statistical period
          sum double Sum of Metrics within the statistical period
          minimum double Minimum value of Metrics within the statistical period
          maximum double Maximum value of Metrics within the counting cycle
          sampleCount Integer Number of DataPoints for the Metric within the statistical period
          timestamp DateTime, refer to [Date and Time](BCM/API Reference/General Description.md#Date and time regulations), expressed in UTC date Time corresponding to the statistical period of Metric

          Request example

          dimensions := map[string]string{
              "InstanceId": "xxx",
          }
          req := &bcm.GetMetricDataRequest{
              UserId:         "xxx",
              Scope:          "BCE_BCC",
              MetricName:     "vCPUUsagePercent",
              Dimensions:     dimensions,
              Statistics:     strings.Split(bcm.Average, ","),
              PeriodInSecond: 60,
              StartTime:      time.Now().UTC().Add(-2 * time.Hour).Format("2006-01-02T15:04:05Z"),
              EndTime:        time.Now().UTC().Add(-1 * time.Hour).Format("2006-01-02T15:04:05Z"),
          }
          resp, err := bcmClient.GetMetricData(req)
          Previous
          Overview
          Next
          Query Latest Metric Data for Partial Dimensions