-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #116 from GoogleCloudPlatform/monitoringv3
Add Monitoring v3 Samples
- Loading branch information
Showing
12 changed files
with
876 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 --> | ||
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
Oops, something went wrong.