forked from googleapis/python-logging
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate readmes for most service samples [(googleapis#599)](GoogleCl…
- Loading branch information
Jon Wayne Parrott
authored
Oct 24, 2016
1 parent
958a4f9
commit c1d1f0d
Showing
3 changed files
with
189 additions
and
36 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
.. This file is automatically generated. Do not edit this file directly. | ||
Stackdriver Logging Python Samples | ||
=============================================================================== | ||
|
||
This directory contains samples for Stackdriver Logging. `Stackdriver Logging`_ allows you to store, search, analyze, monitor, and alert on log data and events from Google Cloud Platform and Amazon Web Services. | ||
|
||
|
||
|
||
|
||
.. _Stackdriver Logging: https://cloud.google.com/logging/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 | ||
------------------------------------------------------------------------------- | ||
|
||
Quickstart | ||
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
|
||
|
||
|
||
To run this sample: | ||
|
||
.. code-block:: bash | ||
$ python quickstart.py | ||
Snippets | ||
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
|
||
|
||
|
||
To run this sample: | ||
|
||
.. code-block:: bash | ||
$ python snippets.py | ||
usage: snippets.py [-h] logger_name {list,write,delete} ... | ||
This application demonstrates how to perform basic operations on logs and | ||
log entries with Stackdriver Logging. | ||
For more information, see the README.md under /logging and the | ||
documentation at https://cloud.google.com/logging/docs. | ||
positional arguments: | ||
logger_name Logger name | ||
{list,write,delete} | ||
list Lists the most recent entries for a given logger. | ||
write Writes log entries to the given logger. | ||
delete Deletes a logger and all its entries. Note that a | ||
deletion can take several minutes to take effect. | ||
optional arguments: | ||
-h, --help show this help message and exit | ||
Export | ||
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
|
||
|
||
|
||
To run this sample: | ||
|
||
.. code-block:: bash | ||
$ python export.py | ||
usage: export.py [-h] {list,create,update,delete} ... | ||
positional arguments: | ||
{list,create,update,delete} | ||
list Lists all sinks. | ||
create Lists all sinks. | ||
update Changes a sink's filter. The filter determines which | ||
logs this sink matches and will be exported to the | ||
destination. For example a filter of 'severity>=INFO' | ||
will send all logs that have a severity of INFO or | ||
greater to the destination. See https://cloud.google.c | ||
om/logging/docs/view/advanced_filters for more filter | ||
information. | ||
delete Deletes a sink. | ||
optional arguments: | ||
-h, --help show this help message and exit | ||
The client library | ||
------------------------------------------------------------------------------- | ||
This sample uses the `Google Cloud Client Library for Python`_. | ||
You can read the documentation for more details on API usage and use GitHub | ||
to `browse the source`_ and `report issues`_. | ||
.. Google Cloud Client Library for Python: | ||
https://googlecloudplatform.github.io/google-cloud-python/ | ||
.. browse the source: | ||
https://github.com/GoogleCloudPlatform/google-cloud-python | ||
.. report issues: | ||
https://github.com/GoogleCloudPlatform/google-cloud-python/issues | ||
.. _Google Cloud SDK: https://cloud.google.com/sdk/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# This file is used to generate README.rst | ||
|
||
product: | ||
name: Stackdriver Logging | ||
short_name: Stackdriver Logging | ||
url: https://cloud.google.com/logging/docs | ||
description: > | ||
`Stackdriver Logging`_ allows you to store, search, analyze, monitor, | ||
and alert on log data and events from Google Cloud Platform and Amazon | ||
Web Services. | ||
|
||
setup: | ||
- auth | ||
- install_deps | ||
|
||
samples: | ||
- name: Quickstart | ||
file: quickstart.py | ||
- name: Snippets | ||
file: snippets.py | ||
show_help: true | ||
- name: Export | ||
file: export.py | ||
show_help: true | ||
|
||
cloud_client_library: true |