@@ -6,47 +6,39 @@ Monitoring API to retrieve API data.
6
6
` create_custom_metric.js ` demonstrates how to create a custom metric, write a timeseries value to it,
7
7
and read it back.
8
8
9
-
10
9
# Run locally
11
10
12
11
Create local credentials by running the following command and following the oauth2 flow:
13
12
14
13
gcloud beta auth application-default login
15
14
16
- Then to run:
15
+ Then to run:
17
16
18
17
npm install
19
18
node list_resources.js <YOUR-PROJECT-ID>
20
19
node create_custom_metric.js <YOUR-PROJECT-ID>
21
20
22
-
23
21
## Running on GCE, GAE, or other environments
24
22
25
23
On Google App Engine, the credentials should be found automatically.
26
24
27
25
On Google Compute Engine, the credentials should be found automatically, but require that
28
- you create the instance with the correct scopes.
26
+ you create the instance with the correct scopes.
29
27
30
28
gcloud compute instances create --scopes="https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/compute,https://www.googleapis.com/auth/compute.readonly" test-instance
31
29
32
- If you did not create the instance with the right scopes, you can still upload a JSON service
30
+ If you did not create the instance with the right scopes, you can still upload a JSON service
33
31
account and set GOOGLE_APPLICATION_CREDENTIALS as described below.
34
32
35
-
36
33
## Using a Service Account
37
34
38
35
In non-Google Cloud environments, GCE instances created without the correct scopes, or local
39
- workstations if the ` gcloud beta auth application-default login ` command fails, use a Service
36
+ workstations if the ` gcloud beta auth application-default login ` command fails, use a Service
40
37
Account by doing the following:
41
38
42
39
* Go to API Manager -> Credentials
43
- * Click 'New Credentials', and create a Service Account or [ click here] (https://console.cloud.google
44
- .com/project/_ /apiui/credential/serviceaccount)
45
- Download the JSON for this service account, and set the ` GOOGLE_APPLICATION_CREDENTIALS `
46
- environment variable to point to the file containing the JSON credentials.
47
-
40
+ * Click 'New Credentials', and create a Service Account or [ click here] ( https://console.cloud.google.com/project/_/apiui/credential/serviceaccount )
41
+ * Download the JSON for this service account, and set the ` GOOGLE_APPLICATION_CREDENTIALS `
42
+ environment variable to point to the file containing the JSON credentials.
48
43
49
44
export GOOGLE_APPLICATION_CREDENTIALS=~/Downloads/<project-id>-0123456789abcdef.json
50
-
51
-
52
-
0 commit comments