|
| 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 | +To run the sample, you need to enable the API at: https://console.cloud.google.com/apis/library/monitoring.googleapis.com |
| 18 | + |
| 19 | +To run the sample, you need to have `Monitoring Admin` role. |
| 20 | + |
| 21 | +Please visit [the Cloud Console UI of this API](https://console.cloud.google.com/monitoring) and [create a new Workspace with the same name of your Cloud project](https://cloud.google.com/monitoring/workspaces/create). |
| 22 | + |
| 23 | + |
| 24 | +Setup |
| 25 | +------------------------------------------------------------------------------- |
| 26 | + |
| 27 | + |
| 28 | +Authentication |
| 29 | +++++++++++++++ |
| 30 | + |
| 31 | +This sample requires you to have authentication setup. Refer to the |
| 32 | +`Authentication Getting Started Guide`_ for instructions on setting up |
| 33 | +credentials for applications. |
| 34 | + |
| 35 | +.. _Authentication Getting Started Guide: |
| 36 | + https://cloud.google.com/docs/authentication/getting-started |
| 37 | + |
| 38 | +Install Dependencies |
| 39 | +++++++++++++++++++++ |
| 40 | + |
| 41 | +#. Clone python-docs-samples and change directory to the sample directory you want to use. |
| 42 | + |
| 43 | + .. code-block:: bash |
| 44 | +
|
| 45 | + $ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git |
| 46 | +
|
| 47 | +#. 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. |
| 48 | + |
| 49 | + .. _Python Development Environment Setup Guide: |
| 50 | + https://cloud.google.com/python/setup |
| 51 | + |
| 52 | +#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+. |
| 53 | + |
| 54 | + .. code-block:: bash |
| 55 | +
|
| 56 | + $ virtualenv env |
| 57 | + $ source env/bin/activate |
| 58 | +
|
| 59 | +#. Install the dependencies needed to run the samples. |
| 60 | + |
| 61 | + .. code-block:: bash |
| 62 | +
|
| 63 | + $ pip install -r requirements.txt |
| 64 | +
|
| 65 | +.. _pip: https://pip.pypa.io/ |
| 66 | +.. _virtualenv: https://virtualenv.pypa.io/ |
| 67 | + |
| 68 | +Samples |
| 69 | +------------------------------------------------------------------------------- |
| 70 | + |
| 71 | +Snippets |
| 72 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 73 | + |
| 74 | +.. image:: https://gstatic.com/cloudssh/images/open-btn.png |
| 75 | + :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 |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | + |
| 80 | +To run this sample: |
| 81 | + |
| 82 | +.. code-block:: bash |
| 83 | +
|
| 84 | + $ python snippets.py |
| 85 | +
|
| 86 | + usage: snippets.py [-h] |
| 87 | + {list-alert-policies,list-notification-channels,enable-alert-policies,disable-alert-policies,replace-notification-channels,backup,restore} |
| 88 | + ... |
| 89 | +
|
| 90 | + Demonstrates AlertPolicy API operations. |
| 91 | +
|
| 92 | + positional arguments: |
| 93 | + {list-alert-policies,list-notification-channels,enable-alert-policies,disable-alert-policies,replace-notification-channels,backup,restore} |
| 94 | + list-alert-policies |
| 95 | + list-notification-channels |
| 96 | + enable-alert-policies |
| 97 | + Enable or disable alert policies in a project. |
| 98 | + Arguments: project_name (str) enable (bool): Enable or |
| 99 | + disable the policies. filter_ (str, optional): Only |
| 100 | + enable/disable alert policies that match this filter_. |
| 101 | + See |
| 102 | + https://cloud.google.com/monitoring/api/v3/sorting- |
| 103 | + and-filtering |
| 104 | + disable-alert-policies |
| 105 | + Enable or disable alert policies in a project. |
| 106 | + Arguments: project_name (str) enable (bool): Enable or |
| 107 | + disable the policies. filter_ (str, optional): Only |
| 108 | + enable/disable alert policies that match this filter_. |
| 109 | + See |
| 110 | + https://cloud.google.com/monitoring/api/v3/sorting- |
| 111 | + and-filtering |
| 112 | + replace-notification-channels |
| 113 | + backup |
| 114 | + restore |
| 115 | +
|
| 116 | + optional arguments: |
| 117 | + -h, --help show this help message and exit |
| 118 | +
|
| 119 | +
|
| 120 | +
|
| 121 | +
|
| 122 | +
|
| 123 | +The client library |
| 124 | +------------------------------------------------------------------------------- |
| 125 | + |
| 126 | +This sample uses the `Google Cloud Client Library for Python`_. |
| 127 | +You can read the documentation for more details on API usage and use GitHub |
| 128 | +to `browse the source`_ and `report issues`_. |
| 129 | + |
| 130 | +.. _Google Cloud Client Library for Python: |
| 131 | + https://googlecloudplatform.github.io/google-cloud-python/ |
| 132 | +.. _browse the source: |
| 133 | + https://github.com/GoogleCloudPlatform/google-cloud-python |
| 134 | +.. _report issues: |
| 135 | + https://github.com/GoogleCloudPlatform/google-cloud-python/issues |
| 136 | + |
| 137 | + |
| 138 | +.. _Google Cloud SDK: https://cloud.google.com/sdk/ |
0 commit comments