百度智能云

All Product Document

          Cloud Monitor

          Push Custom Monitor Data API

          API description

          Push time-series data to BCM for monitoring. With the Custom Monitor feature, you can transmit time-series data to BCM via this API for real-time monitoring.

          Request body

          PushCustomMetricDataRequest

          Name Types Description Required or not
          userId String Tenant ID Yes
          namespace String Scope Yes
          metricName String Monitor item name Yes
          dimensions List<Dimension> Dimension Yes
          value double Either the value of the Monitor item or statisticValues must not empty No
          statisticValues StatisticValues The statistic value of the Monitor item and the value must have at least one non-empty field No
          timestamp String, refer to [Date and Time](BCM/API Reference/General Description.md#Date and time regulations), expressed in UTC date Time Yes

          Dimension

          Name Types Description Required or not
          name String Dimension name Yes
          value String Dimension value Yes

          StatisticValues

          Name Types Description Required or not
          maximum double Maximum value Yes
          minimum double Minimum value Yes
          average double Average Value Yes
          sum double And Value Yes
          sampleCount integer Sample count Yes

          Response Body

          PushMetricDataResponse

          Name Types Description
          requestId String Request identifier
          message String Error message
          success boolean Succeeded or not

          Request example

              // create a bcm client
              String endpoint = "bcm.bj.baidubce.com";
              String userId = "fakeuser1ba678asdf8as7df6a5sdf67";
              String ak = "ak";
              String sk = "sk";
              BcmClientConfiguration config = new BcmClientConfiguration();
              config.setCredentials(new DefaultBceCredentials(ak, sk));
              config.setEndpoint(endpoint);
              BcmClient client = new BcmClient(config);
              // push custom metric data with value and no dimension
              PushCustomMetricDataRequest request = PushCustomMetricDataRequest.builder()
                      .userId(userId)
                      .namespace("test_wang")
                      .metricName("test_api_no_dimension")
                      .value(10.0)
                      .timestamp(DateUtils.formatAlternateIso8601Date(new Date(System.currentTimeMillis() - 10 * 60 * 1000)))
                      .build();
              PushMetricDataResponse response = client.pushCustomMonitorMetricData(request);
              System.out.println(JsonUtils.toJsonString(response));
              // push custom metric data with statistic value and dimension
              List<Dimension> dimensions = new ArrayList<>();
              dimensions.add(new Dimension().withName("dimension1").withValue("d1"));
              dimensions.add(new Dimension().withName("dimension2").withValue("d2"));
              StatisticValue value = StatisticValue.builder()
                      .maximum(1.0).minimum(2.0).sum(3.0).sampleCount(1).average(4.0).build();
              request = PushCustomMetricDataRequest.builder()
                      .userId(userId)
                      .namespace("test_wang")
                      .metricName("test_api_time")
                      .dimensions(dimensions)
                      .statisticValues(value)
                      .timestamp(DateUtils.formatAlternateIso8601Date(new Date(System.currentTimeMillis() - 10 * 60 * 1000)))
                      .build();
              response = client.pushCustomMonitorMetricData(request);
              System.out.println(JsonUtils.toJsonString(response));
          Previous
          Overview
          Next
          Query Data API