百度智能云

All Product Document

          Cloud Monitor

          Batch Query Monitoring Data Interface V2

          API description

          API to obtain data for multiple instances, multiple metrics, and multiple statistics, including Cloud Product Monitor data, Site Monitor data, or Custom Monitor data pushed by users.

          API restriction

          • For any metric of a specific instance, the number of data points returned in one response cannot exceed 1,440.
          • A single request can query up to 100 instances.

          Request parameters

          Name Types Description Required or not Parameter location
          userId string User ID Yes Body
          scope string For cloud product identifiers, please refer to [Cloud Product Identifier List](BCM/Cloud Product Monitor List/Cloud Product Monitor Object Type List.md) Yes Body
          region string Region identifier. For values, refer to [Region List](BCM/API Reference/Service domain.md) Yes Body
          type string Monitor object type, refer to [Monitor Object Type List](BCM/Cloud Product Monitor List/Cloud Product Monitor Object Type List.md) Yes Body
          metricNames string[] The list of Monitor Metrics is limited to the following character set: "0~9, A~Z, a~z", "_"
          . When searching for multiple Metric items, use a String array, with each array element being a Metric item
          Yes Body
          statistics string[] The list of Statistic Method Types includes average, maximum, minimum, sum, and sampleCount. To query multiple Statistic values, use a String array Yes Body
          dimensions Dimension[] List of dimensions. When querying data for multiple instances, use a two-dimensional array: the first-level array specifies multiple instances, and the second-level array specifies multiple dimensions. Yes Body
          startTime string Query start time, please refer to [Date and Time](BCM/API Reference/General Description.md#Date and time regulations), expressed in UTC Yes Body
          endTime string Query end time, please refer to [Date and Time](BCM/API Reference/General Description.md#Date and time regulations), expressed in UTC Yes Body
          cycle int Statistic Period, multiples of 60, unit: seconds Yes Body

          Dimension

          Name Types Description
          name string Dimension key
          value string Dimension value

          Parameter explanation

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

          Response result

          Name Types Description
          requestId string Request identifier
          code string Return code
          message string Error message
          metrics AllDataMetric[] Monitor Metric

          AllDataMetric

          Name Types Description
          region string Region
          scope string Cloud product identifier
          userId string User ID
          resourceId string Resource ID
          metricName string Metric name
          dimensions Dimension[] Dimension list
          dataPoints DataPoints[] Metric data

          DataPoints

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

          Request example

          req := &model.TsdbMetricAllDataQueryRequest{
              UserID: "453bf9********************9090dc",
              Scope:  "BCE_BCC",
              Region: "bj",
              Type: "Instance",
              Dimensions: [][]model.Dimension{
                  {
                      {
                          Name:  "InstanceId",
                          Value: "i-DMxr6UxX",
                      },
                  },
                  {
                      {
                          Name:  "InstanceId",
                          Value: "i-Y8NAmymd",
                      },
                  },
              },
              Statistics:  []string{"average", "sum"},
              StartTime:   "2024-03-20T07:01:00Z",
              EndTime:     "2024-03-20T07:05:00Z",
              MetricNames: []string{"CPUUsagePercent", "MemUsedPercent"},
          }
          response, err := bcmClient.GetMetricsAllDataV2(req)

          Response result

          {
                "requestId": "54dbc0dc-185c-4821-987c-36a50d6f853d",
                "code": "success",
                "message": "",
                "metrics": [
                      {
                            "region": "bj",
                            "scope": "BCE_BCC",
                            "userId": "453bf9588c9e488f9ba2c984129090dc",
                            "resourceId": "i-DMxr6UxX",
                            "metricName": "CPUUsagePercent",
                            "dimensions": [
                                  {
                                        "name": "InstanceId",
                                        "value": "i-DMxr6UxX"
                                  }
                            ],
                            "dataPoints": [
                                  {
                                        "average": 7.883685650352,
                                        "sum": 15.767371300704,
                                        "timestamp": "2024-03-20T07:01:00Z"
                                  }
                            ]
                      },
                      {
                            "region": "bj",
                            "scope": "BCE_BCC",
                            "userId": "453bf9588c9e488f9ba2c984129090dc",
                            "resourceId": "i-Y8NAmymd",
                            "metricName": "CPUUsagePercent",
                            "dimensions": [
                                  {
                                        "name": "InstanceId",
                                        "value": "i-Y8NAmymd"
                                  }
                            ],
                            "dataPoints": [
                                  {
                                        "average": 28.7611908111665,
                                        "sum": 57.522381622333,
                                        "timestamp": "2024-03-20T07:01:00Z"
                                  }
                            ]
                      },
                      {
                            "region": "bj",
                            "scope": "BCE_BCC",
                            "userId": "453bf9588c9e488f9ba2c984129090dc",
                            "resourceId": "i-DMxr6UxX",
                            "metricName": "MemUsedPercent",
                            "dimensions": [
                                  {
                                        "name": "InstanceId",
                                        "value": "i-DMxr6UxX"
                                  }
                            ],
                            "dataPoints": [
                                  {
                                        "average": 20.727214027726,
                                        "sum": 41.454428055452,
                                        "timestamp": "2024-03-20T07:01:00Z"
                                  }
                            ]
                      },
                      {
                            "region": "bj",
                            "scope": "BCE_BCC",
                            "userId": "453bf9588c9e488f9ba2c984129090dc",
                            "resourceId": "i-Y8NAmymd",
                            "metricName": "MemUsedPercent",
                            "dimensions": [
                                  {
                                        "name": "InstanceId",
                                        "value": "i-Y8NAmymd"
                                  }
                            ],
                            "dataPoints": [
                                  {
                                        "average": 20.772412679829998,
                                        "sum": 41.544825359659995,
                                        "timestamp": "2024-03-20T07:01:00Z"
                                  }
                            ]
                      }
                ]
          }
          Previous
          Batch Data Query Interface
          Next
          BcmClient