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

Commit

Permalink
Generate readmes for most service samples [(#599)](GoogleCloudPlatfor…
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Wayne Parrott authored Oct 24, 2016
1 parent a6707f6 commit b8820ff
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 71 deletions.
71 changes: 0 additions & 71 deletions samples/snippets/v3/README.md

This file was deleted.

136 changes: 136 additions & 0 deletions samples/snippets/v3/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
.. This file is automatically generated. Do not edit this file directly.
Stackdriver Monitoring Python Samples
===============================================================================

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.




.. _Stackdriver Monitoring: https://cloud.google.com/monitoring/docs

Setup
-------------------------------------------------------------------------------


Authentication
++++++++++++++

Authentication is typically done through `Application Default Credentials`_,
which means you do not have to change the code to authenticate as long as
your environment has credentials. You have a few options for setting up
authentication:

#. When running locally, use the `Google Cloud SDK`_

.. code-block:: bash
gcloud beta auth application-default login
#. When running on App Engine or Compute Engine, credentials are already
set-up. However, you may need to configure your Compute Engine instance
with `additional scopes`_.

#. You can create a `Service Account key file`_. This file can be used to
authenticate to Google Cloud Platform services from any environment. To use
the file, set the ``GOOGLE_APPLICATION_CREDENTIALS`` environment variable to
the path to the key file, for example:

.. code-block:: bash
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service_account.json
.. _Application Default Credentials: https://cloud.google.com/docs/authentication#getting_credentials_for_server-centric_flow
.. _additional scopes: https://cloud.google.com/compute/docs/authentication#using
.. _Service Account key file: https://developers.google.com/identity/protocols/OAuth2ServiceAccount#creatinganaccount

Install Dependencies
++++++++++++++++++++

#. Install `pip`_ and `virtualenv`_ if you do not already have them.

#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+.

.. code-block:: bash
$ virtualenv env
$ source env/bin/activate
#. Install the dependencies needed to run the samples.

.. code-block:: bash
$ pip install -r requirements.txt
.. _pip: https://pip.pypa.io/
.. _virtualenv: https://virtualenv.pypa.io/

Samples
-------------------------------------------------------------------------------

List resources
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



To run this sample:

.. code-block:: bash
$ python list_resources.py
usage: list_resources.py [-h] --project_id PROJECT_ID
Sample command-line program for retrieving Stackdriver Monitoring API V3
data.
See README.md for instructions on setting up your development environment.
To run locally:
python list_resources.py --project_id=<YOUR-PROJECT-ID>
optional arguments:
-h, --help show this help message and exit
--project_id PROJECT_ID
Project ID you want to access.
Custom metrics
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



To run this sample:

.. code-block:: bash
$ python custom_metric.py
usage: custom_metric.py [-h] --project_id PROJECT_ID
Sample command-line program for writing and reading Stackdriver Monitoring
API V3 custom metrics.
Simple command-line program to demonstrate connecting to the Google
Monitoring API to write custom metrics and read them back.
See README.md for instructions on setting up your development environment.
This example creates a custom metric based on a hypothetical GAUGE measurement.
To run locally:
python custom_metric.py --project_id=<YOUR-PROJECT-ID>
optional arguments:
-h, --help show this help message and exit
--project_id PROJECT_ID
Project ID you want to access.
.. _Google Cloud SDK: https://cloud.google.com/sdk/
25 changes: 25 additions & 0 deletions samples/snippets/v3/README.rst.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This file is used to generate README.rst

product:
name: Stackdriver Monitoring
short_name: Stackdriver Monitoring
url: https://cloud.google.com/monitoring/docs
description: >
`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.

setup:
- auth
- install_deps

samples:
- name: List resources
file: list_resources.py
show_help: true
- name: Custom metrics
file: custom_metric.py
show_help: true

0 comments on commit b8820ff

Please sign in to comment.