Skip to content

Commit b825077

Browse files
authored
fix-it(Cloud Monitoring Api): Change the quick start documentation. (GoogleCloudPlatform#3150)
- 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.
1 parent 78b4812 commit b825077

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

monitoring/cloud-client/src/main/java/com/example/monitoring/QuickstartSample.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public static void main(String... args) throws Exception {
5555
TimeInterval.newBuilder()
5656
.setEndTime(Timestamps.fromMillis(System.currentTimeMillis()))
5757
.build();
58-
TypedValue value = TypedValue.newBuilder().setDoubleValue(123.45).build();
58+
TypedValue value = TypedValue.newBuilder().setDoubleValue(3.14).build();
5959
Point point = Point.newBuilder().setInterval(interval).setValue(value).build();
6060

6161
List<Point> pointList = new ArrayList<>();
@@ -68,15 +68,16 @@ public static void main(String... args) throws Exception {
6868
metricLabels.put("store_id", "Pittsburg");
6969
Metric metric =
7070
Metric.newBuilder()
71-
.setType("custom.googleapis.com/stores/daily_sales")
71+
.setType("custom.googleapis.com/my_metric")
7272
.putAllLabels(metricLabels)
7373
.build();
7474

7575
// Prepares the monitored resource descriptor
7676
Map<String, String> resourceLabels = new HashMap<String, String>();
77-
resourceLabels.put("project_id", projectId);
77+
resourceLabels.put("instance_id", "1234567890123456789");
78+
resourceLabels.put("zone", "us-central1-f");
7879
MonitoredResource resource =
79-
MonitoredResource.newBuilder().setType("global").putAllLabels(resourceLabels).build();
80+
MonitoredResource.newBuilder().setType("gce_instance").putAllLabels(resourceLabels).build();
8081

8182
// Prepares the time series request
8283
TimeSeries timeSeries =

0 commit comments

Comments
 (0)