Skip to content

Commit

Permalink
Merge pull request #85 from GoogleCloudPlatform/monitoringtests
Browse files Browse the repository at this point in the history
Add Monitoring Tests
  • Loading branch information
jmdobry committed Mar 30, 2016
2 parents 86d488c + 78bd52d commit 29bf77a
Show file tree
Hide file tree
Showing 5 changed files with 408 additions and 278 deletions.
22 changes: 7 additions & 15 deletions monitoring/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,47 +6,39 @@ Monitoring API to retrieve API data.
`create_custom_metric.js` demonstrates how to create a custom metric, write a timeseries value to it,
and read it back.


# Run locally

Create local credentials by running the following command and following the oauth2 flow:

gcloud beta auth application-default login

Then to run:
Then to run:

npm install
node list_resources.js <YOUR-PROJECT-ID>
node create_custom_metric.js <YOUR-PROJECT-ID>


## Running on GCE, GAE, or other environments

On Google App Engine, the credentials should be found automatically.

On Google Compute Engine, the credentials should be found automatically, but require that
you create the instance with the correct scopes.
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
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
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.

* 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



Loading

0 comments on commit 29bf77a

Please sign in to comment.