百度智能云

All Product Document

          Cloud Monitor

          View the Data Interface

          Interface Description

          The time series data of one or more statistical data of designated indexes are acquired. The cloud product monitoring data, the site monitoring data or the custom monitoring data pushed by you can be acquired.

          Interface Restriction

          • The number of data points returned at one time cannot exceed 1,440.

          Request Parameter

          Name Type Description Necessary or not Parameter position
          user_id String Tenant ID Yes URL parameter
          scope String, only limited to usage of the following character sets: "0~9、A~Z、a~z"、 "_". Name space Yes URL parameter
          metric_name String, only limited to usage of the following character sets: "0~9、A~Z、a~z"、 "_". Monitoring index name Yes URL parameter
          statistics Statistics, the optional values are average, maximum, minimum, sum, samplecount according to statistics1, statistics2 and statistics3 formats. Type of statistical method Yes Query parameter
          dimensions String, composed of dimensionName:dimensionValue. The monitoring items are connected by semicolons when they have multiple dimensions, e.g. dimensionName: dimensionValue; dimensionName: dimensionValue. One dimension value can be designated only for the same dimension. Dimension list Yes Query parameter
          start_time For DateTime, please refer to date and time, and it is represented by UTC date. Start time of query Yes Query parameter
          end_time For DateTime, please refer to date and time, and it is represented by UTC date. End time of query Yes Query parameter
          period_in_second Integer, multiple of 60, unit: Seconds(s) Statistical period Yes Query parameter

          Parameter explanation

          • For the concepts of scope, metric, statistic, Dimension, etc., please refer to Core Concept.

          Response Parameter

          Name Type Description
          request_id String Request identification
          code String Return code
          message String Error message
          data_points List(data_point) Monitoring index

          data_point

          Name Type Description
          average double Average value of monitoring items in the statistical period
          sum double Sum value of monitoring items in the statistical period
          minimum double Minimum value of monitoring items in the statistical period
          maximum double Maximum value of monitoring items in the statistical period
          sample_count Integer Data points of monitoring items in the statistical period
          timestamp For DateTime, please refer to Date and Time, and it is represented by UTC date. Time corresponding to the statistical period of monitoring items

          Request Example

              # params definition
              user_id = "fakeuser1ba678asdf8as7df6a5sdf67"
              scope = "BCE_BCC"
              metric_name = "vCPUUsagePercent"
              dimensions = "InstanceId:fakeid-2222-8888-1111-13a8469b1fb2"
              statistics = "average,maximum,minimum"
              start_time = "2019-04-16T13:55:01Z"
              end_time = "2019-04-16T14:00:01Z"
              period_in_second = 60
          
              # create a bcm client
              bcm_client = BcmClient(bcm_sample_conf.config)
          
              # query metric data from bcm interface
              try:
                  response = bcm_client.get_metric_data(user_id=user_id,
                                                        scope=scope,
                                                        metric_name=metric_name,
                                                        dimensions=dimensions,
                                                        statistics=statistics,
                                                        start_time=start_time,
                                                        end_time=end_time,
                                                        period_in_second=period_in_second)
                  print(response)
              except BceHttpClientError as e:
                  if isinstance(e.last_error, BceServerError):
                      __logger.error('send request failed. Response %s, code: %s, msg: %s'
                                     % (e.last_error.status_code, e.last_error.code, e.last_error.message))
                  else:
                      __logger.error('send request failed. Unknown exception: %s' % e)
          Previous
          BcmClient
          Next
          BCM Agent