Skip to main content

Amazon Web Services Cloud Watch Metrics Library

https://img.shields.io/pypi/v/awsme.svg https://img.shields.io/travis/peterdemin/awsme.svg Updates

Configurable client library, that supports asynchronous and buffered sending of AWS cloud watch metrics.

Installation

By default awsme is installed without boto3 dependency to make it deploy faster in AWS Lambda environment (See #3 <https://github.com/peterdemin/awsme/issues/3> for details).

If you run awsme outside of Lambda, use following command to activate boto3 dependency:

pip install awsme[boto3]

Usage

from awsme import create_cloud_watch
cloud_watch = create_cloud_watch(
    namespace='Application',
    dimensions={'version': '1.0.0'},
)
cloud_watch.log('metric', dimensions={'key': 'dim'}, value=123)

Create Options

create_cloud_watch accepts following arguments:

  • asynchronous (optional bool): if True (default), send metrics from a separate thread.

  • buffered (optional bool): if True (default), metrics will be accumulated in a buffer and sent in batches.

  • dummy (optional bool): if True, ignore two previous options and create dummy recorder. False by default.

  • dimensions: (optional Dict[str, str]): dictionary of default dimensions, that will be attached to all metrics.

  • All other kwargs will be bypassed to boto3.client('cloudwatch', **kwargs)

Log Options

CloudWatch, returned by create_cloud_watch has two public methods. The primary method is log. It’s arguments:

  • name (required str): name of the metric.

  • dimensions (optional Dict[str, str]): additional dimensions, that will be added to default dimension from factory.

  • value (optional float): metric’s value, 1 by default.

  • unit (optional str): metric unit, e.g. Count, Seconds, Bytes, see AWS docs for a complete list of valid values.

  • storage_resolution (optional int): metric storage resolution in seconds, 60 by default.

Flushing

If create_cloud_watch was called with buffered=True (default) then you may want to forcefully flush the internal metrics buffer. In a standard application this will likely not be necessary, as the buffer will auto-flush atexit. However, if your application is running as an AWS Lambda function, the execution of the Lambda function will be “frozen” when the function completes, preventing exiting and thus flushing. In this use case, you will need to forcibly flush the buffer by calling flush. It’s argument:

  • complete (optional bool): if True (default), perform a complete flush.

AWS configuration

Awsme uses boto3 library, that takes configuration from environment variables and configuration files. To check, that you have everything configured properly to send metrics, use included command-line tool:

$ awsme-test
...
Successfully sent metric "awsme-test" to "Test Namespace"

Credits

This package was created with Cookiecutter and the elgertam/cookiecutter-pipenv project template, based on audreyr/cookiecutter-pypackage.

History

0.2.2 (2019-01-24)

  • Added asynchronous recorder and user documentation

0.1.0 (2018-11-13)

  • First release on PyPI.

Metadata

Release files for awsme 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for awsme 1.0.0
File Size Uploaded
awsme-1.0.0.tar.gz 33.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for awsme 1.0.0
File Interpreter ABI Platform
awsme-1.0.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 42.9 kB

Release files / awsme-1.0.0.tar.gz

Download URL awsme-1.0.0.tar.gz
Size 33.3 kB
Tags Source
SHA-256 checksum
How to use checksums
ef97279d2638ed348786af517f4fedc4ede6bc022388fe07ddd1c3a0cddc9a32
BLAKE2b-256 checksum
How to use checksums
187d0ffac18e358b9cfd9743bd0d7aae2449937e2577d79dea255edd9088491b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.3

Release files / awsme-1.0.0-py2.py3-none-any.whl

Download URL awsme-1.0.0-py2.py3-none-any.whl
Size 9.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
cce8899e8369a5f0dbe1f00fd203eeda904d7a1369ce53b2ba5cdca34f99b565
BLAKE2b-256 checksum
How to use checksums
ba9aa2d1387ec1408c8b3335c66817fc7210e8799b20c78bce79b2ac71b09a8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.3

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page