Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
Add Alerting samples. (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdobry authored May 4, 2018
1 parent 80caff6 commit d428e7c
Show file tree
Hide file tree
Showing 10 changed files with 638 additions and 21 deletions.
7 changes: 7 additions & 0 deletions .cloud-repo-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
"client_reference_url": "https://cloud.google.com/nodejs/docs/reference/monitoring/latest/",
"release_quality": "beta",
"samples": [
{
"id": "alerts",
"name": "Alert Policies",
"file": "alerts.js",
"docs_link": "https://cloud.google.com/monitoring/docs",
"usage": "node alerts.js --help"
},
{
"id": "metrics",
"name": "Metrics",
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
.nyc_output
docs/
out/
build/
system-test/secrets.js
system-test/*key.json
*.lock
.DS_Store
google-cloud-logging-winston-*.tgz
google-cloud-logging-bunyan-*.tgz
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[//]: # "This README.md file is auto-generated, all changes to this file will be lost."
[//]: # "To regenerate it, use `npm run generate-scaffolding`."
<img src="https://avatars2.githubusercontent.com/u/2810941?v=3&s=96" alt="Google Cloud Platform logo" title="Google Cloud Platform" align="right" height="96" width="96"/>

# [Stackdriver Monitoring: Node.js Client](https://github.com/googleapis/nodejs-monitoring)
Expand Down Expand Up @@ -126,6 +128,7 @@ has instructions for running the samples.

| Sample | Source Code | Try it |
| --------------------------- | --------------------------------- | ------ |
| Alert Policies | [source code](https://github.com/googleapis/nodejs-monitoring/blob/master/samples/alerts.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-monitoring&page=editor&open_in_editor=samples/alerts.js,samples/README.md) |
| Metrics | [source code](https://github.com/googleapis/nodejs-monitoring/blob/master/samples/metrics.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-monitoring&page=editor&open_in_editor=samples/metrics.js,samples/README.md) |
| Uptime Config | [source code](https://github.com/googleapis/nodejs-monitoring/blob/master/samples/uptime.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-monitoring&page=editor&open_in_editor=samples/uptime.js,samples/README.md) |

Expand Down Expand Up @@ -157,4 +160,4 @@ See [LICENSE](https://github.com/googleapis/nodejs-monitoring/blob/master/LICENS

[client-docs]: https://cloud.google.com/nodejs/docs/reference/monitoring/latest/
[product-docs]: https://cloud.google.com/monitoring/docs
[shell_img]: //gstatic.com/cloudssh/images/open-btn.png
[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"lodash.union": "^4.6.0"
},
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "^2.2.3",
"@google-cloud/nodejs-repo-tools": "^2.3.0",
"async": "^2.5.0",
"codecov": "^3.0.0",
"eslint": "^4.9.0",
Expand Down
1 change: 1 addition & 0 deletions samples/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
policies_backup.json
72 changes: 61 additions & 11 deletions samples/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[//]: # "This README.md file is auto-generated, all changes to this file will be lost."
[//]: # "To regenerate it, use `npm run generate-scaffolding`."
<img src="https://avatars2.githubusercontent.com/u/2810941?v=3&s=96" alt="Google Cloud Platform logo" title="Google Cloud Platform" align="right" height="96" width="96"/>

# Stackdriver Monitoring: Node.js Samples
Expand All @@ -10,6 +12,7 @@

* [Before you begin](#before-you-begin)
* [Samples](#samples)
* [Alert Policies](#alert-policies)
* [Metrics](#metrics)
* [Uptime Config](#uptime-config)

Expand All @@ -21,9 +24,56 @@ library's README.

## Samples

### Alert Policies

View the [source code][alerts_0_code].

[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-monitoring&page=editor&open_in_editor=samples/alerts.js,samples/README.md)

__Usage:__ `node alerts.js --help`

```
alerts.js <command>
Commands:
alerts.js backup <projectId> Save alert policies to a ./policies_backup.json file.
alerts.js restore <projectId> Restore alert policies from a ./policies_backup.json file.
alerts.js replace <alertPolicyName> <channelNames..> Replace the notification channels of the specified alert policy.
alerts.js disable <projectId> [filter] Disables policies that match the given filter.
alerts.js enable <projectId> [filter] Enables policies that match the given filter.
Options:
--version Show version number [boolean]
--alertPolicyName [string]
--help Show help [boolean]
Examples:
node alerts.js backup my-project-id Backup policies.
node alerts.js restore my-project-id Restore policies.
node alerts.js replace Replace the notification channels of the specified alert
projects/my-project-id/alertPolicies/12345 channel-1 policy.
channel-2 channel-3
node alerts.js disable my-project-id "(NOT Disables policies that match the given filter.
display_name.empty OR NOT description.empty) AND
user_labels='active'"
node alerts.js disable my-project-id "description:'cloud'" Disables policies that match the given filter.
node alerts.js disable my-project-id Disables policies that match the given filter.
"display_name=monitoring.regex.full_match('Temp \d{4}')"
node alerts.js enable my-project-id "(NOT display_name.empty Enables policies that match the given filter.
OR NOT description.empty) AND user_labels='active'"
node alerts.js enable my-project-id "description:'cloud'" Enables policies that match the given filter.
node alerts.js enable my-project-id Enables policies that match the given filter.
"display_name=monitoring.regex.full_match('Temp \d{4}')"
For more information, see https://cloud.google.com/monitoring/docs/
```

[alerts_0_docs]: https://cloud.google.com/monitoring/docs
[alerts_0_code]: alerts.js

### Metrics

View the [source code][metrics_0_code].
View the [source code][metrics_1_code].

[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-monitoring&page=editor&open_in_editor=samples/metrics.js,samples/README.md)

Expand Down Expand Up @@ -52,7 +102,7 @@ Commands:
Options:
--version Show version number [boolean]
--projectId, -p [string]
--projectId, -p [string] [default: "nodejs-docs-samples"]
--help Show help [boolean]
Examples:
Expand All @@ -71,12 +121,12 @@ Examples:
For more information, see https://cloud.google.com/monitoring/docs
```

[metrics_0_docs]: https://cloud.google.com/monitoring/docs
[metrics_0_code]: metrics.js
[metrics_1_docs]: https://cloud.google.com/monitoring/docs
[metrics_1_code]: metrics.js

### Uptime Config

View the [source code][uptime_1_code].
View the [source code][uptime_2_code].

[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-monitoring&page=editor&open_in_editor=samples/uptime.js,samples/README.md)

Expand All @@ -86,19 +136,19 @@ __Usage:__ `node uptime.js --help`
uptime.js <command>
Commands:
uptime.js create <gceInstanceId> [projectId] Creates an uptime check config.
uptime.js create <hostname> [projectId] Creates an uptime check config.
uptime.js list [projectId] Lists uptime check configs.
uptime.js list-ips Lists uptime check config IPs.
uptime.js get <uptimeCheckConfigId> [projectId] Gets an uptime check config.
uptime.js delete <uptimeCheckConfigId> [projectId] Deletes an uptime check config.
Options:
--version Show version number [boolean]
--projectId, -p [string]
--projectId, -p [string] [default: "nodejs-docs-samples"]
--help Show help [boolean]
Examples:
node uptime.js create my-instance Create an uptime check for a "my-instance" GCE instance.
node uptime.js create mydomain.com Create an uptime check.
node uptime.js list List all uptime check configs.
node uptime.js list "resource.type = gce_instance AND List all uptime check configs for a specific GCE
resource.label.instance_id = mongodb" instance.
Expand All @@ -109,8 +159,8 @@ Examples:
For more information, see https://cloud.google.com/monitoring/uptime-checks/
```

[uptime_1_docs]: https://cloud.google.com/monitoring/docs
[uptime_1_code]: uptime.js
[uptime_2_docs]: https://cloud.google.com/monitoring/docs
[uptime_2_code]: uptime.js

[shell_img]: //gstatic.com/cloudssh/images/open-btn.png
[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png
[shell_link]: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-monitoring&page=editor&open_in_editor=samples/README.md
Loading

0 comments on commit d428e7c

Please sign in to comment.