From 128cecd2715c91915b61581e76703a0475594cb1 Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 11 Jun 2020 16:20:20 -0400 Subject: [PATCH] fix-it(Cloud Monitoring Api): Change the quick start documentation. - Change the quick start metric to `custom.googleapis.com/my_metric` - Change the type to "gce_instance". Justification: Cloud monitoring api team discourage using "global" resource type for custom metric, and to align the sample, I change the metric type also. --- .../java/com/example/monitoring/QuickstartSample.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/monitoring/cloud-client/src/main/java/com/example/monitoring/QuickstartSample.java b/monitoring/cloud-client/src/main/java/com/example/monitoring/QuickstartSample.java index fcfd392a43f..6b6e2579736 100644 --- a/monitoring/cloud-client/src/main/java/com/example/monitoring/QuickstartSample.java +++ b/monitoring/cloud-client/src/main/java/com/example/monitoring/QuickstartSample.java @@ -55,7 +55,7 @@ public static void main(String... args) throws Exception { TimeInterval.newBuilder() .setEndTime(Timestamps.fromMillis(System.currentTimeMillis())) .build(); - TypedValue value = TypedValue.newBuilder().setDoubleValue(123.45).build(); + TypedValue value = TypedValue.newBuilder().setDoubleValue(3.14).build(); Point point = Point.newBuilder().setInterval(interval).setValue(value).build(); List pointList = new ArrayList<>(); @@ -68,15 +68,16 @@ public static void main(String... args) throws Exception { metricLabels.put("store_id", "Pittsburg"); Metric metric = Metric.newBuilder() - .setType("custom.googleapis.com/stores/daily_sales") + .setType("custom.googleapis.com/my_metric") .putAllLabels(metricLabels) .build(); // Prepares the monitored resource descriptor Map resourceLabels = new HashMap(); - resourceLabels.put("project_id", projectId); + resourceLabels.put("instance_id", "1234567890123456789"); + resourceLabels.put("zone", "us-central1-f"); MonitoredResource resource = - MonitoredResource.newBuilder().setType("global").putAllLabels(resourceLabels).build(); + MonitoredResource.newBuilder().setType("gce_instance").putAllLabels(resourceLabels).build(); // Prepares the time series request TimeSeries timeSeries =