Skip to content
This repository was archived by the owner on Dec 31, 2023. It is now read-only.

Commit b8820ff

Browse files
author
Jon Wayne Parrott
authored
Generate readmes for most service samples [(#599)](GoogleCloudPlatform/python-docs-samples#599)
1 parent a6707f6 commit b8820ff

File tree

3 files changed

+161
-71
lines changed

3 files changed

+161
-71
lines changed

samples/snippets/v3/README.md

Lines changed: 0 additions & 71 deletions
This file was deleted.

samples/snippets/v3/README.rst

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
.. This file is automatically generated. Do not edit this file directly.
2+
3+
Stackdriver Monitoring Python Samples
4+
===============================================================================
5+
6+
This directory contains samples for Stackdriver Monitoring. `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 ingests that data and generates insights via dashboards, charts, and alerts.
7+
8+
9+
10+
11+
.. _Stackdriver Monitoring: https://cloud.google.com/monitoring/docs
12+
13+
Setup
14+
-------------------------------------------------------------------------------
15+
16+
17+
Authentication
18+
++++++++++++++
19+
20+
Authentication is typically done through `Application Default Credentials`_,
21+
which means you do not have to change the code to authenticate as long as
22+
your environment has credentials. You have a few options for setting up
23+
authentication:
24+
25+
#. When running locally, use the `Google Cloud SDK`_
26+
27+
.. code-block:: bash
28+
29+
gcloud beta auth application-default login
30+
31+
32+
#. When running on App Engine or Compute Engine, credentials are already
33+
set-up. However, you may need to configure your Compute Engine instance
34+
with `additional scopes`_.
35+
36+
#. You can create a `Service Account key file`_. This file can be used to
37+
authenticate to Google Cloud Platform services from any environment. To use
38+
the file, set the ``GOOGLE_APPLICATION_CREDENTIALS`` environment variable to
39+
the path to the key file, for example:
40+
41+
.. code-block:: bash
42+
43+
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service_account.json
44+
45+
.. _Application Default Credentials: https://cloud.google.com/docs/authentication#getting_credentials_for_server-centric_flow
46+
.. _additional scopes: https://cloud.google.com/compute/docs/authentication#using
47+
.. _Service Account key file: https://developers.google.com/identity/protocols/OAuth2ServiceAccount#creatinganaccount
48+
49+
Install Dependencies
50+
++++++++++++++++++++
51+
52+
#. Install `pip`_ and `virtualenv`_ if you do not already have them.
53+
54+
#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+.
55+
56+
.. code-block:: bash
57+
58+
$ virtualenv env
59+
$ source env/bin/activate
60+
61+
#. Install the dependencies needed to run the samples.
62+
63+
.. code-block:: bash
64+
65+
$ pip install -r requirements.txt
66+
67+
.. _pip: https://pip.pypa.io/
68+
.. _virtualenv: https://virtualenv.pypa.io/
69+
70+
Samples
71+
-------------------------------------------------------------------------------
72+
73+
List resources
74+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
75+
76+
77+
78+
To run this sample:
79+
80+
.. code-block:: bash
81+
82+
$ python list_resources.py
83+
84+
usage: list_resources.py [-h] --project_id PROJECT_ID
85+
86+
Sample command-line program for retrieving Stackdriver Monitoring API V3
87+
data.
88+
89+
See README.md for instructions on setting up your development environment.
90+
91+
To run locally:
92+
93+
python list_resources.py --project_id=<YOUR-PROJECT-ID>
94+
95+
optional arguments:
96+
-h, --help show this help message and exit
97+
--project_id PROJECT_ID
98+
Project ID you want to access.
99+
100+
101+
Custom metrics
102+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
103+
104+
105+
106+
To run this sample:
107+
108+
.. code-block:: bash
109+
110+
$ python custom_metric.py
111+
112+
usage: custom_metric.py [-h] --project_id PROJECT_ID
113+
114+
Sample command-line program for writing and reading Stackdriver Monitoring
115+
API V3 custom metrics.
116+
117+
Simple command-line program to demonstrate connecting to the Google
118+
Monitoring API to write custom metrics and read them back.
119+
120+
See README.md for instructions on setting up your development environment.
121+
122+
This example creates a custom metric based on a hypothetical GAUGE measurement.
123+
124+
To run locally:
125+
126+
python custom_metric.py --project_id=<YOUR-PROJECT-ID>
127+
128+
optional arguments:
129+
-h, --help show this help message and exit
130+
--project_id PROJECT_ID
131+
Project ID you want to access.
132+
133+
134+
135+
136+
.. _Google Cloud SDK: https://cloud.google.com/sdk/

samples/snippets/v3/README.rst.in

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# This file is used to generate README.rst
2+
3+
product:
4+
name: Stackdriver Monitoring
5+
short_name: Stackdriver Monitoring
6+
url: https://cloud.google.com/monitoring/docs
7+
description: >
8+
`Stackdriver Monitoring `_ collects metrics, events, and metadata from
9+
Google Cloud Platform, Amazon Web Services (AWS), hosted uptime probes,
10+
application instrumentation, and a variety of common application components
11+
including Cassandra, Nginx, Apache Web Server, Elasticsearch and many
12+
others. Stackdriver ingests that data and generates insights via
13+
dashboards, charts, and alerts.
14+
15+
setup:
16+
- auth
17+
- install_deps
18+
19+
samples:
20+
- name: List resources
21+
file: list_resources.py
22+
show_help: true
23+
- name: Custom metrics
24+
file: custom_metric.py
25+
show_help: true

0 commit comments

Comments
 (0)