Skip to content

Commit

Permalink
Merge pull request #132 from GoogleCloudPlatform/gcloud-adc
Browse files Browse the repository at this point in the history
Update README.md
  • Loading branch information
tswast committed Mar 22, 2016
2 parents cc5513c + d67d2f9 commit 1b58407
Showing 1 changed file with 32 additions and 14 deletions.
46 changes: 32 additions & 14 deletions monitoring/v3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,43 @@ write a TimeSeries value to it.

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

# Set Up Your Local Dev Environment

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

* Go too API Manager -> Credentials
* Click ['New Credentials', and create a Service Account](https://console.developers.google.com/project/_/apiui/credential/serviceaccount)
Download the JSON for this service account, and set the
`GOOGLE_APPLICATION_CREDENTIALS` environment variable to point to the file
containing the JSON credentials.
gcloud beta auth application-default login

To run:
* `mvn clean install`
* `./list_resources_example.sh <YOUR-PROJECT-ID>
* `./run_custom_metrics.sh <YOUR-PROJECT-ID>

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

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

To run locally:
* `mvn clean install`
* `./list_resources_example.sh <YOUR-PROJECT-ID>
* `./run_custom_metrics.sh <YOUR-PROJECT-ID>
On Google Compute Engine, the credentials should be found automatically, but require that
you create the instance with the correct scopes.

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

If you did not create the instance with the right scopes, you can still upload a JSON service
account and set GOOGLE_APPLICATION_CREDENTIALS as described below.

## Using a Service Account

In non-Google Cloud environments, GCE instances created without the correct scopes, or local
workstations if the `gcloud beta auth application-default login` command fails, use a Service
Account by doing the following:

* Go to API Manager -> Credentials
* Click 'New Credentials', and create a Service Account or [click here](https://console.cloud.google
.com/project/_/apiui/credential/serviceaccount)
Download the JSON for this service account, and set the `GOOGLE_APPLICATION_CREDENTIALS`
environment variable to point to the file containing the JSON credentials.


export GOOGLE_APPLICATION_CREDENTIALS=~/Downloads/<project-id>-0123456789abcdef.json

## Run Tests

Expand Down

0 comments on commit 1b58407

Please sign in to comment.