Skip to content

Commit d67d2f9

Browse files
committed
Update README.md
1 parent cc5513c commit d67d2f9

File tree

1 file changed

+32
-14
lines changed

1 file changed

+32
-14
lines changed

monitoring/v3/README.md

+32-14
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,43 @@ write a TimeSeries value to it.
1010

1111
* [Maven 3](https://maven.apache.org)
1212

13+
# Set Up Your Local Dev Environment
1314

14-
Go to the [Google Developers Console](https://console.developer.google.com).
15+
Create local credentials by running the following command and following the oauth2 flow:
1516

16-
* Go too API Manager -> Credentials
17-
* Click ['New Credentials', and create a Service Account](https://console.developers.google.com/project/_/apiui/credential/serviceaccount)
18-
Download the JSON for this service account, and set the
19-
`GOOGLE_APPLICATION_CREDENTIALS` environment variable to point to the file
20-
containing the JSON credentials.
17+
gcloud beta auth application-default login
18+
19+
To run:
20+
* `mvn clean install`
21+
* `./list_resources_example.sh <YOUR-PROJECT-ID>
22+
* `./run_custom_metrics.sh <YOUR-PROJECT-ID>
2123

22-
```
23-
export GOOGLE_APPLICATION_CREDENTIALS=~/Downloads/<project-id>-0123456789abcdef.json
24-
```
24+
## Running on GCE, GAE, or other environments
2525

26-
# Set Up Your Local Dev Environment
26+
On Google App Engine, the credentials should be found automatically.
2727

28-
To run locally:
29-
* `mvn clean install`
30-
* `./list_resources_example.sh <YOUR-PROJECT-ID>
31-
* `./run_custom_metrics.sh <YOUR-PROJECT-ID>
28+
On Google Compute Engine, the credentials should be found automatically, but require that
29+
you create the instance with the correct scopes.
30+
31+
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
32+
33+
If you did not create the instance with the right scopes, you can still upload a JSON service
34+
account and set GOOGLE_APPLICATION_CREDENTIALS as described below.
35+
36+
## Using a Service Account
37+
38+
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
40+
Account by doing the following:
41+
42+
* 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+
48+
49+
export GOOGLE_APPLICATION_CREDENTIALS=~/Downloads/<project-id>-0123456789abcdef.json
3250

3351
## Run Tests
3452

0 commit comments

Comments
 (0)