Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2.9k
Add Monitoring v3 Samples#116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # Cloud Monitoring Sample | ||
| Simple command-line program to demonstrate connecting to the Google | ||
| Monitoring API to retrieve API data. | ||
| This also includes an example of how to create a cusom metric and | ||
| write a TimeSeries value to it. | ||
| ## Prerequisites to run locally: | ||
| * [Maven 3](https://maven.apache.org) | ||
| Go to the [Google Developers Console](https://console.developer.google.com). | ||
| * 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. | ||
| ``` | ||
| export GOOGLE_APPLICATION_CREDENTIALS=~/Downloads/<project-id>-0123456789abcdef.json | ||
| ``` | ||
| # Set Up Your Local Dev Environment | ||
| To run locally: | ||
| * `mvn clean install` | ||
| * `./run_monitoring_example.sh <YOUR-PROJECT-ID> | ||
| * `./run_custom_metrics.sh <YOUR-PROJECT-ID> | ||
| ## Run Tests | ||
| The tests emulate what the scripts accomplish, so there isn't a reason why they need to be run if the examples work. | ||
| However, if you'd like to run them, change TEST_PROJECT_ID in ListResourcesTest to the appropriate project ID | ||
| that matches the Service Account pointed to by GOOGLE_APPLICATION_CREDENTIALS, then run: | ||
| mvn test -DskipTests=false | ||
| ## Contributing changes | ||
| See CONTRIBUTING.md | ||
| ## Licensing | ||
| * See [LICENSE](LICENSE) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| #!/usr/bin/env bash | ||
| mvn exec:java -Dexec.mainClass=ListResources -Dexec.args="$1" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
| <groupId>com.google.cloud.monotoring.samples</groupId> | ||
| <artifactId>cloud-monitoring-v3-samples</artifactId> | ||
| <version>0.1-SNAPSHOT</version> | ||
| <packaging>jar</packaging> | ||
| <parent> | ||
| <artifactId>doc-samples</artifactId> | ||
| <groupId>com.google.cloud</groupId> | ||
| <version>1.0.0</version> | ||
| <relativePath>../..</relativePath> | ||
| </parent> | ||
| <properties> | ||
| <project.http.version>1.19.0</project.http.version> | ||
| <project.oauth.version>1.19.0</project.oauth.version> | ||
| <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| <skipTests>true</skipTests> | ||
| </properties> | ||
| <dependencies> | ||
| <dependency> | ||
| <groupId>com.google.api-client</groupId> | ||
| <artifactId>google-api-client</artifactId> | ||
| <version>1.20.0</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.google.oauth-client</groupId> | ||
| <artifactId>google-oauth-client</artifactId> | ||
| <version>${project.oauth.version}</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.google.http-client</groupId> | ||
| <artifactId>google-http-client-jackson2</artifactId> | ||
| <version>${project.http.version}</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.google.oauth-client</groupId> | ||
| <artifactId>google-oauth-client-jetty</artifactId> | ||
| <version>${project.oauth.version}</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.google.code.gson</groupId> | ||
| <artifactId>gson</artifactId> | ||
| <version>2.3.1</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>junit</groupId> | ||
| <artifactId>junit</artifactId> | ||
| <scope>test</scope> | ||
| <version>4.12</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.jcabi</groupId> | ||
| <artifactId>jcabi-matchers</artifactId> | ||
| <scope>test</scope> | ||
| <version>1.3</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>joda-time</groupId> | ||
| <artifactId>joda-time</artifactId> | ||
| <version>2.9</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.apache.commons</groupId> | ||
| <artifactId>commons-lang3</artifactId> | ||
| <version>3.4</version> | ||
| </dependency> | ||
| <!-- To be replaced by a Maven dependency on public release --> | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment no longer relevant. (I assume this maven dependency is now public) Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed by #122. | ||
| <dependency> | ||
| <groupId>com.google.apis</groupId> | ||
| <artifactId>google-api-services-monitoring</artifactId> | ||
| <version>v3-rev1-1.21.0</version> | ||
| </dependency> | ||
| </dependencies> | ||
| <build> | ||
| <pluginManagement> | ||
| <plugins> | ||
| <plugin> | ||
| <artifactId>maven-compiler-plugin</artifactId> | ||
| <version>2.3.2</version> | ||
| <configuration> | ||
| <source>1.7</source> | ||
| <target>1.7</target> | ||
| </configuration> | ||
| </plugin> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-surefire-plugin</artifactId> | ||
| <version>2.4.2</version> | ||
| <configuration> | ||
| <skipTests>${skipTests}</skipTests> | ||
| </configuration> | ||
| </plugin> | ||
| </plugins> | ||
| </pluginManagement> | ||
| </build> | ||
| </project> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| #!/usr/bin/env bash | ||
| mvn exec:java -Dexec.mainClass=CreateCustomMetric -Dexec.args="$1" |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] extra new line here