Skip to content

Commit fdae234

Browse files
evaogbestephenplusplus
authored andcommitted
Update monitoring client (#2526)
1 parent 36e7e41 commit fdae234

19 files changed

Lines changed: 2463 additions & 294 deletions

README.md

Lines changed: 71 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ This client supports the following Google Cloud Platform services at a [Beta](#v
2323
* [Cloud Spanner](#cloud-spanner-beta) (Beta)
2424
* [Cloud Vision](#cloud-vision-beta) (Beta)
2525
* [Google BigQuery](#google-bigquery-beta) (Beta)
26+
* [Google Stackdriver Monitoring](#google-stackdriver-monitoring-beta) (Beta)
2627

2728
This client supports the following Google Cloud Platform services at an [Alpha](#versioning) quality level:
2829

@@ -36,7 +37,6 @@ This client supports the following Google Cloud Platform services at an [Alpha](
3637
* [Google Stackdriver Debugger](#google-stackdriver-debugger-alpha) (Alpha)
3738
* [Google Stackdriver Error Reporting](#google-stackdriver-error-reporting-alpha) (Alpha)
3839
* [Google Stackdriver Trace](#google-stackdriver-trace-alpha) (Alpha)
39-
* [Google Stackdriver Monitoring](#google-stackdriver-monitoring-alpha) (Alpha)
4040

4141
If you need support for other Google APIs, check out the [Google Node.js API Client library][googleapis].
4242

@@ -620,6 +620,75 @@ job.getQueryResults().on('data', function(row) {});
620620
```
621621

622622

623+
## Google Stackdriver Monitoring (Beta)
624+
625+
### :warning: This is an auto-generated API
626+
627+
It does not follow the conventions you're familiar with from other parts of our library. A handwritten layer is not yet available.
628+
629+
The example below shows you how to instantiate the generated client. For further documentation, please browse the [Monitoring .proto files][cloud-monitoring-protos] on GitHub.
630+
631+
- [API Documentation][gcloud-monitoring-docs]
632+
- [Official Documentation][cloud-monitoring-docs]
633+
634+
#### Using the Google Stackdriver Monitoring API module
635+
636+
```
637+
$ npm install --save @google-cloud/monitoring
638+
```
639+
640+
```js
641+
var monitoring = require('@google-cloud/monitoring');
642+
```
643+
644+
#### Preview
645+
646+
```js
647+
var client = monitoring.metric({
648+
// optional auth parameters.
649+
});
650+
651+
// Iterate over all elements.
652+
var formattedName = client.projectPath(projectId);
653+
654+
client.listMonitoredResourceDescriptors({name: formattedName}).then(function(responses) {
655+
var resources = responses[0];
656+
for (var i = 0; i < resources.length; ++i) {
657+
// doThingsWith(resources[i])
658+
}
659+
})
660+
.catch(function(err) {
661+
console.error(err);
662+
});
663+
664+
// Or obtain the paged response.
665+
var formattedName = client.projectPath(projectId);
666+
667+
668+
var options = {autoPaginate: false};
669+
function callback(responses) {
670+
// The actual resources in a response.
671+
var resources = responses[0];
672+
// The next request if the response shows there's more responses.
673+
var nextRequest = responses[1];
674+
// The actual response object, if necessary.
675+
// var rawResponse = responses[2];
676+
for (var i = 0; i < resources.length; ++i) {
677+
// doThingsWith(resources[i]);
678+
}
679+
if (nextRequest) {
680+
// Fetch the next page.
681+
return client.listMonitoredResourceDescriptors(nextRequest, options).then(callback);
682+
}
683+
}
684+
client.listMonitoredResourceDescriptors({name: formattedName}, options)
685+
.then(callback)
686+
.catch(function(err) {
687+
console.error(err);
688+
});
689+
```
690+
691+
623692
## Cloud Bigtable (Alpha)
624693

625694
- [API Documentation][gcloud-bigtable-docs]
@@ -1017,34 +1086,6 @@ errors.report(new Error('Something broke!'));
10171086

10181087
For more details on API usage, please see the [documentation][stackdriver-errors-module].
10191088

1020-
## Google Stackdriver Monitoring (Alpha)
1021-
1022-
### :warning: This is an auto-generated API
1023-
1024-
It does not follow the conventions you're familiar with from other parts of our library. A handwritten layer is not yet available.
1025-
1026-
The example below shows you how to instantiate the generated client. For further documentation, please browse the [Monitoring .proto files][cloud-monitoring-protos] on GitHub.
1027-
1028-
- [Official Documentation][cloud-monitoring-docs]
1029-
1030-
#### Using the Google Stackdriver Monitoring API module
1031-
1032-
```
1033-
$ npm install --save @google-cloud/monitoring
1034-
```
1035-
1036-
```js
1037-
var monitoring = require('@google-cloud/monitoring');
1038-
```
1039-
1040-
#### Preview
1041-
1042-
```js
1043-
var monitoringClient = monitoring.v3({
1044-
projectId: 'grape-spaceship-123',
1045-
keyFilename: '/path/to/keyfile.json'
1046-
});
1047-
```
10481089

10491090
## Google Stackdriver Trace (Alpha)
10501091

@@ -1104,6 +1145,7 @@ Apache 2.0 - See [COPYING][copying] for more information.
11041145
[gcloud-language-docs]: https://googlecloudplatform.github.io/google-cloud-node/#/docs/language
11051146
[gcloud-logging-docs]: https://googlecloudplatform.github.io/google-cloud-node/#/docs/logging
11061147
[gcloud-prediction-docs]: https://googlecloudplatform.github.io/google-cloud-node/#/docs/prediction
1148+
[gcloud-monitoring-docs]: https://googlecloudplatform.github.io/google-cloud-node/#/docs/monitoring
11071149
[gcloud-pubsub-docs]: https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub
11081150
[gcloud-resource-docs]: https://googlecloudplatform.github.io/google-cloud-node/#/docs/resource
11091151
[gcloud-spanner-docs]: https://googlecloudplatform.github.io/google-cloud-node/#/docs/spanner

packages/monitoring/README.md

Lines changed: 64 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,75 @@
1-
# @google-cloud/monitoring ([Alpha][versioning])
2-
> Google Stackdriver Monitoring Client Library for Node.js
1+
# Node.js Clients for Stackdriver Monitoring API ([Beta](https://github.com/GoogleCloudPlatform/google-cloud-node#versioning))
32

4-
*Looking for more Google APIs than just Monitoring? You might want to check out [`google-cloud`][google-cloud].*
3+
[Stackdriver Monitoring API][Product Documentation]: Manages your Stackdriver Monitoring data and configurations. Most projects must be associated with a Stackdriver account, with a few exceptions as noted on the individual method pages.
54

6-
- [Official Documentation][cloud-monitoring-docs]
5+
- [Client Library Documentation][]
6+
- [Product Documentation][]
77

8-
## This is an auto-generated API
8+
## Quick Start
9+
In order to use this library, you first need to go through the following steps:
910

10-
It does not follow the conventions you're familiar with from other parts of our library. A handwritten layer is not yet available.
11+
1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
12+
2. [Enable the Stackdriver Monitoring API.](https://console.cloud.google.com/apis/api/monitoring)
13+
3. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-node/#/docs/google-cloud/master/guides/authentication)
1114

12-
The example below shows you how to instantiate the generated client. For further documentation, please browse the [Monitoring .proto files][cloud-monitoring-protos] on GitHub.
13-
14-
15-
```sh
16-
$ npm install --save @google-cloud/monitoring
17-
```
18-
```js
19-
var monitoring = require('@google-cloud/monitoring').v3({
20-
projectId: 'grape-spaceship-123',
21-
keyFilename: '/path/to/keyfile.json'
22-
});
15+
### Installation
2316
```
24-
25-
26-
## Authentication
27-
28-
It's incredibly easy to get authenticated and start using Google's APIs. You can set your credentials on a global basis as well as on a per-API basis. See each individual API section below to see how you can auth on a per-API-basis. This is useful if you want to use different accounts for different Cloud services.
29-
30-
### On Google Cloud Platform
31-
32-
If you are running this client on Google Cloud Platform, we handle authentication for you with no configuration. You just need to make sure that when you [set up the GCE instance][gce-how-to], you add the correct scopes for the APIs you want to access.
33-
34-
``` js
35-
// Authenticating on a global basis.
36-
var monitoring = require('@google-cloud/monitoring').v3();
37-
// ...you're good to go!
17+
$ npm install --save @google-cloud/monitoring
3818
```
3919

40-
### Elsewhere
41-
42-
If you are not running this client on Google Cloud Platform, you need a Google Developers service account. To create a service account:
43-
44-
1. Visit the [Google Developers Console][dev-console].
45-
2. Create a new project or click on an existing project.
46-
3. Navigate to **APIs & auth** > **Credentials** and then:
47-
* If you want to use a new service account key, click on **Create credentials** and select **Service account key**. After the account key is created, you will be prompted to download the JSON key file that the library uses to authenticate your requests.
48-
* If you want to generate a new service account key for an existing service account, click on **Generate new JSON key** and download the JSON key file.
49-
50-
``` js
51-
var monitoring = require('@google-cloud/monitoring').v3({
52-
// The path to your key file:
53-
keyFilename: '/path/to/keyfile.json'
54-
55-
// Or the contents of the key file:
56-
credentials: require('./path/to/keyfile.json')
57-
});
58-
59-
// ...you're good to go!
20+
### Preview
21+
#### MetricServiceClient
22+
```js
23+
var monitoring = require('@google-cloud/monitoring');
24+
25+
var client = monitoring.metric({
26+
// optional auth parameters.
27+
});
28+
29+
// Iterate over all elements.
30+
var formattedName = client.projectPath(projectId);
31+
32+
client.listMonitoredResourceDescriptors({name: formattedName}).then(function(responses) {
33+
var resources = responses[0];
34+
for (var i = 0; i < resources.length; ++i) {
35+
// doThingsWith(resources[i])
36+
}
37+
})
38+
.catch(function(err) {
39+
console.error(err);
40+
});
41+
42+
// Or obtain the paged response.
43+
var formattedName = client.projectPath(projectId);
44+
45+
46+
var options = {autoPaginate: false};
47+
function callback(responses) {
48+
// The actual resources in a response.
49+
var resources = responses[0];
50+
// The next request if the response shows there's more responses.
51+
var nextRequest = responses[1];
52+
// The actual response object, if necessary.
53+
// var rawResponse = responses[2];
54+
for (var i = 0; i < resources.length; ++i) {
55+
// doThingsWith(resources[i]);
56+
}
57+
if (nextRequest) {
58+
// Fetch the next page.
59+
return client.listMonitoredResourceDescriptors(nextRequest, options).then(callback);
60+
}
61+
}
62+
client.listMonitoredResourceDescriptors({name: formattedName}, options)
63+
.then(callback)
64+
.catch(function(err) {
65+
console.error(err);
66+
});
6067
```
6168

69+
### Next Steps
70+
- Read the [Client Library Documentation][] for Stackdriver Monitoring API to see other available methods on the client.
71+
- Read the [Stackdriver Monitoring API Product documentation][Product Documentation] to learn more about the product and see How-to Guides.
72+
- View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-node/blob/master/README.md) to see the full list of Cloud APIs that we cover.
6273

63-
[versioning]: https://github.com/GoogleCloudPlatform/google-cloud-node#versioning
64-
[google-cloud]: https://github.com/GoogleCloudPlatform/google-cloud-node/
65-
[gce-how-to]: https://cloud.google.com/compute/docs/authentication#using
66-
[dev-console]: https://console.developers.google.com/project
67-
[cloud-monitoring-docs]: https://cloud.google.com/monitoring/docs
68-
[cloud-monitoring-protos]: https://github.com/googleapis/googleapis/tree/master/google/monitoring/v3
74+
[Client Library Documentation]: https://googlecloudplatform.github.io/google-cloud-node/#/docs/monitoring
75+
[Product Documentation]: https://cloud.google.com/monitoring

packages/monitoring/package.json

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,13 @@
11
{
2-
"repository": "googlecloudplatform/google-cloud-node",
2+
"repository": "GoogleCloudPlatform/google-cloud-node",
33
"name": "@google-cloud/monitoring",
44
"version": "0.2.3",
5-
"author": "Google Inc.",
6-
"description": "Stackdriver Monitoring Client Library for Node.js",
7-
"contributors": [
8-
{
9-
"name": "Burcu Dogan",
10-
"email": "jbd@google.com"
11-
},
12-
{
13-
"name": "Johan Euphrosine",
14-
"email": "proppy@google.com"
15-
},
16-
{
17-
"name": "Patrick Costello",
18-
"email": "pcostell@google.com"
19-
},
20-
{
21-
"name": "Ryan Seys",
22-
"email": "ryan@ryanseys.com"
23-
},
24-
{
25-
"name": "Silvano Luciani",
26-
"email": "silvano@google.com"
27-
},
28-
{
29-
"name": "Stephen Sawchuk",
30-
"email": "sawchuk@gmail.com"
31-
}
32-
],
5+
"author": "Google Inc",
6+
"description": "Stackdriver Monitoring API client for Node.js",
337
"main": "src/index.js",
348
"files": [
359
"src",
3610
"AUTHORS",
37-
"CONTRIBUTING",
3811
"COPYING"
3912
],
4013
"keywords": [
@@ -48,19 +21,19 @@
4821
"cloud",
4922
"google monitoring",
5023
"monitoring",
51-
"stackdriver monitoring",
52-
"stackdriver"
24+
"Stackdriver Monitoring API"
5325
],
5426
"dependencies": {
55-
"extend": "^3.0.0",
56-
"google-gax": "^0.13.0",
27+
"extend": "^3.0",
28+
"google-gax": "^0.13.2",
5729
"google-proto-files": "^0.12.0"
5830
},
5931
"devDependencies": {
60-
"mocha": "^3.1.2"
32+
"mocha": "^3.2.0"
6133
},
6234
"scripts": {
6335
"publish-module": "node ../../scripts/publish.js monitoring",
36+
"smoke-test": "mocha smoke-test/*.js --timeout 5000",
6437
"test": "mocha test/*.js"
6538
},
6639
"license": "Apache-2.0",

0 commit comments

Comments
 (0)