Skip to content

Commit 87af05c

Browse files
Stackdriver monitoring alerts sample. (#1475)
* Stackdriver monitoring alerts sample. * Lint * py27 tests pass * Accomodate reviewer's comments. * Add spaces around code blocks, Inc => LLC, and add docstring. * Reformat doc comments to look like Google doc comments.
1 parent fcb6493 commit 87af05c

File tree

8 files changed

+612
-0
lines changed

8 files changed

+612
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
backup.json
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
.. This file is automatically generated. Do not edit this file directly.
2+
3+
Google Stackdriver Alerting API Python Samples
4+
===============================================================================
5+
6+
.. image:: https://gstatic.com/cloudssh/images/open-btn.png
7+
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=monitoring/api/v3/alerts-client/README.rst
8+
9+
10+
This directory contains samples for Google Stackdriver Alerting API. Stackdriver Monitoring collects metrics, events, and metadata from Google Cloud Platform, Amazon Web Services (AWS), hosted uptime probes, application instrumentation, and a variety of common application components including Cassandra, Nginx, Apache Web Server, Elasticsearch and many others. Stackdriver's Alerting API allows you to create, delete, and make back up copies of your alert policies.
11+
12+
13+
14+
15+
.. _Google Stackdriver Alerting API: https://cloud.google.com/monitoring/alerts/
16+
17+
Setup
18+
-------------------------------------------------------------------------------
19+
20+
21+
Authentication
22+
++++++++++++++
23+
24+
This sample requires you to have authentication setup. Refer to the
25+
`Authentication Getting Started Guide`_ for instructions on setting up
26+
credentials for applications.
27+
28+
.. _Authentication Getting Started Guide:
29+
https://cloud.google.com/docs/authentication/getting-started
30+
31+
Install Dependencies
32+
++++++++++++++++++++
33+
34+
#. Clone python-docs-samples and change directory to the sample directory you want to use.
35+
36+
.. code-block:: bash
37+
38+
$ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git
39+
40+
#. Install `pip`_ and `virtualenv`_ if you do not already have them. You may want to refer to the `Python Development Environment Setup Guide`_ for Google Cloud Platform for instructions.
41+
42+
.. _Python Development Environment Setup Guide:
43+
https://cloud.google.com/python/setup
44+
45+
#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+.
46+
47+
.. code-block:: bash
48+
49+
$ virtualenv env
50+
$ source env/bin/activate
51+
52+
#. Install the dependencies needed to run the samples.
53+
54+
.. code-block:: bash
55+
56+
$ pip install -r requirements.txt
57+
58+
.. _pip: https://pip.pypa.io/
59+
.. _virtualenv: https://virtualenv.pypa.io/
60+
61+
Samples
62+
-------------------------------------------------------------------------------
63+
64+
Snippets
65+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
66+
67+
.. image:: https://gstatic.com/cloudssh/images/open-btn.png
68+
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=monitoring/api/v3/alerts-client/snippets.py,monitoring/api/v3/alerts-client/README.rst
69+
70+
71+
72+
73+
To run this sample:
74+
75+
.. code-block:: bash
76+
77+
$ python snippets.py
78+
79+
usage: snippets.py [-h]
80+
{list-alert-policies,list-notification-channels,enable-alert-policies,disable-alert-policies,replace-notification-channels,backup,restore}
81+
...
82+
83+
Demonstrates AlertPolicy API operations.
84+
85+
positional arguments:
86+
{list-alert-policies,list-notification-channels,enable-alert-policies,disable-alert-policies,replace-notification-channels,backup,restore}
87+
list-alert-policies
88+
list-notification-channels
89+
enable-alert-policies
90+
disable-alert-policies
91+
replace-notification-channels
92+
backup
93+
restore
94+
95+
optional arguments:
96+
-h, --help show this help message and exit
97+
98+
99+
100+
101+
102+
The client library
103+
-------------------------------------------------------------------------------
104+
105+
This sample uses the `Google Cloud Client Library for Python`_.
106+
You can read the documentation for more details on API usage and use GitHub
107+
to `browse the source`_ and `report issues`_.
108+
109+
.. _Google Cloud Client Library for Python:
110+
https://googlecloudplatform.github.io/google-cloud-python/
111+
.. _browse the source:
112+
https://github.com/GoogleCloudPlatform/google-cloud-python
113+
.. _report issues:
114+
https://github.com/GoogleCloudPlatform/google-cloud-python/issues
115+
116+
117+
.. _Google Cloud SDK: https://cloud.google.com/sdk/
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# This file is used to generate README.rst
2+
3+
product:
4+
name: Google Stackdriver Alerting API
5+
short_name: Stackdriver Alerting API
6+
url: https://cloud.google.com/monitoring/alerts/
7+
description: >
8+
Stackdriver Monitoring collects metrics, events, and metadata from Google
9+
Cloud Platform, Amazon Web Services (AWS), hosted uptime probes,
10+
application instrumentation, and a variety of common application
11+
components including Cassandra, Nginx, Apache Web Server, Elasticsearch
12+
and many others. Stackdriver's Alerting API allows you to create,
13+
delete, and make back up copies of your alert policies.
14+
15+
setup:
16+
- auth
17+
- install_deps
18+
19+
samples:
20+
- name: Snippets
21+
file: snippets.py
22+
show_help: true
23+
24+
cloud_client_library: true
25+
26+
folder: monitoring/api/v3/alerts-client
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
google-cloud-monitoring==0.29.0
2+
tabulate==0.8.2

0 commit comments

Comments
 (0)