@@ -29,9 +29,11 @@ function createMetricDescriptor (projectId) {
29
29
const Monitoring = require ( '@google-cloud/monitoring' ) ;
30
30
31
31
// Creates a client
32
- const client = Monitoring . v3 . metric ( ) ;
32
+ const client = Monitoring . metric ( ) ;
33
33
34
- // The Google Cloud Platform project on which to execute the request
34
+ /**
35
+ * TODO(developer): Uncomment and edit the following lines of code.
36
+ */
35
37
// const projectId = 'YOUR_PROJECT_ID';
36
38
37
39
const request = {
@@ -82,9 +84,11 @@ function listMetricDescriptors (projectId) {
82
84
const Monitoring = require ( '@google-cloud/monitoring' ) ;
83
85
84
86
// Creates a client
85
- const client = Monitoring . v3 . metric ( ) ;
87
+ const client = Monitoring . metric ( ) ;
86
88
87
- // The Google Cloud Platform project on which to execute the request
89
+ /**
90
+ * TODO(developer): Uncomment and edit the following lines of code.
91
+ */
88
92
// const projectId = 'YOUR_PROJECT_ID';
89
93
90
94
const request = {
@@ -111,13 +115,13 @@ function getMetricDescriptor (projectId, metricId) {
111
115
const Monitoring = require ( '@google-cloud/monitoring' ) ;
112
116
113
117
// Creates a client
114
- const client = Monitoring . v3 . metric ( ) ;
118
+ const client = Monitoring . metric ( ) ;
115
119
116
- // The Google Cloud Platform project on which to execute the request
120
+ /**
121
+ * TODO(developer): Uncomment and edit the following lines of code.
122
+ */
117
123
// const projectId = 'YOUR_PROJECT_ID';
118
-
119
- // An example of "metricId" is "logging.googleapis.com/log_entry_count"
120
- // const metricId = 'some/metric/id';
124
+ // const metricId = 'custom.googleapis.com/your/id';
121
125
122
126
const request = {
123
127
name : client . metricDescriptorPath ( projectId , metricId )
@@ -151,12 +155,12 @@ function deleteMetricDescriptor (projectId, metricId) {
151
155
const Monitoring = require ( '@google-cloud/monitoring' ) ;
152
156
153
157
// Creates a client
154
- const client = Monitoring . v3 . metric ( ) ;
158
+ const client = Monitoring . metric ( ) ;
155
159
156
- // The Google Cloud Platform project on which to execute the request
160
+ /**
161
+ * TODO(developer): Uncomment and edit the following lines of code.
162
+ */
157
163
// const projectId = 'YOUR_PROJECT_ID';
158
-
159
- // The ID of the Metric Descriptor to delete, e.g.
160
164
// const metricId = 'custom.googleapis.com/stores/daily_sales';
161
165
162
166
const request = {
@@ -180,9 +184,11 @@ function writeTimeSeriesData (projectId, metricId) {
180
184
const Monitoring = require ( '@google-cloud/monitoring' ) ;
181
185
182
186
// Creates a client
183
- const client = Monitoring . v3 . metric ( ) ;
187
+ const client = Monitoring . metric ( ) ;
184
188
185
- // The Google Cloud Platform project on which to execute the request
189
+ /**
190
+ * TODO(developer): Uncomment and edit the following lines of code.
191
+ */
186
192
// const projectId = 'YOUR_PROJECT_ID';
187
193
188
194
const dataPoint = {
@@ -238,12 +244,12 @@ function readTimeSeriesData (projectId, filter) {
238
244
const Monitoring = require ( '@google-cloud/monitoring' ) ;
239
245
240
246
// Creates a client
241
- const client = Monitoring . v3 . metric ( ) ;
247
+ const client = Monitoring . metric ( ) ;
242
248
243
- // The Google Cloud Platform project on which to execute the request
249
+ /**
250
+ * TODO(developer): Uncomment and edit the following lines of code.
251
+ */
244
252
// const projectId = 'YOUR_PROJECT_ID';
245
-
246
- // An example "filter" is 'metric.type="compute.googleapis.com/instance/cpu/utilization"'
247
253
// const filter = 'metric.type="compute.googleapis.com/instance/cpu/utilization"';
248
254
249
255
const request = {
@@ -284,9 +290,11 @@ function readTimeSeriesFields (projectId) {
284
290
const Monitoring = require ( '@google-cloud/monitoring' ) ;
285
291
286
292
// Creates a client
287
- const client = Monitoring . v3 . metric ( ) ;
293
+ const client = Monitoring . metric ( ) ;
288
294
289
- // The Google Cloud Platform project on which to execute the request
295
+ /**
296
+ * TODO(developer): Uncomment and edit the following lines of code.
297
+ */
290
298
// const projectId = 'YOUR_PROJECT_ID';
291
299
292
300
const request = {
@@ -328,9 +336,11 @@ function readTimeSeriesAggregate (projectId) {
328
336
const Monitoring = require ( '@google-cloud/monitoring' ) ;
329
337
330
338
// Creates a client
331
- const client = Monitoring . v3 . metric ( ) ;
339
+ const client = Monitoring . metric ( ) ;
332
340
333
- // The Google Cloud Platform project on which to execute the request
341
+ /**
342
+ * TODO(developer): Uncomment and edit the following lines of code.
343
+ */
334
344
// const projectId = 'YOUR_PROJECT_ID';
335
345
336
346
const request = {
@@ -378,9 +388,11 @@ function readTimeSeriesReduce (projectId) {
378
388
const Monitoring = require ( '@google-cloud/monitoring' ) ;
379
389
380
390
// Creates a client
381
- const client = Monitoring . v3 . metric ( ) ;
391
+ const client = Monitoring . metric ( ) ;
382
392
383
- // The Google Cloud Platform project on which to execute the request
393
+ /**
394
+ * TODO(developer): Uncomment and edit the following lines of code.
395
+ */
384
396
// const projectId = 'YOUR_PROJECT_ID';
385
397
386
398
const request = {
@@ -426,9 +438,11 @@ function listMonitoredResourceDescriptors (projectId) {
426
438
const Monitoring = require ( '@google-cloud/monitoring' ) ;
427
439
428
440
// Creates a client
429
- const client = Monitoring . v3 . metric ( ) ;
441
+ const client = Monitoring . metric ( ) ;
430
442
431
- // The Google Cloud Platform project on which to execute the request
443
+ /**
444
+ * TODO(developer): Uncomment and edit the following lines of code.
445
+ */
432
446
// const projectId = 'YOUR_PROJECT_ID';
433
447
434
448
const request = {
@@ -441,7 +455,21 @@ function listMonitoredResourceDescriptors (projectId) {
441
455
const descriptors = results [ 0 ] ;
442
456
443
457
console . log ( 'Monitored Resource Descriptors:' ) ;
444
- descriptors . forEach ( ( descriptor ) => console . log ( descriptor . name ) ) ;
458
+ descriptors . forEach ( ( descriptor ) => {
459
+ if ( descriptor . type === 'uptime_url' ) {
460
+ console . log ( JSON . stringify ( descriptor , null , 2 ) ) ;
461
+ } else {
462
+ return ;
463
+ }
464
+ console . log ( descriptor . name ) ;
465
+ console . log ( ` Type: ${ descriptor . type } ` ) ;
466
+ if ( descriptor . labels ) {
467
+ console . log ( ` Labels:` ) ;
468
+ descriptor . labels . forEach ( ( label ) => {
469
+ console . log ( ` ${ label . key } (${ label . valueType } ): ${ label . description } ` ) ;
470
+ } ) ;
471
+ }
472
+ } ) ;
445
473
} )
446
474
. catch ( ( err ) => {
447
475
console . error ( 'ERROR:' , err ) ;
@@ -455,13 +483,13 @@ function getMonitoredResourceDescriptor (projectId, resourceType) {
455
483
const Monitoring = require ( '@google-cloud/monitoring' ) ;
456
484
457
485
// Creates a client
458
- const client = Monitoring . v3 . metric ( ) ;
486
+ const client = Monitoring . metric ( ) ;
459
487
460
- // The Google Cloud Platform project on which to execute the request
488
+ /**
489
+ * TODO(developer): Uncomment and edit the following lines of code.
490
+ */
461
491
// const projectId = 'YOUR_PROJECT_ID';
462
-
463
- // "resourceType" should be a predefined type, such as "cloudsql_database"
464
- // const resourceType = 'some_resource_type';
492
+ // const resourceType = 'some_resource_type, e.g. cloudsql_database';
465
493
466
494
const request = {
467
495
name : client . monitoredResourceDescriptorPath ( projectId , resourceType )
0 commit comments