AWS Satella

Boto3 configuration

Make sure your boto3 client is configured.

Using aws-satella

In any part of your code (but at least once per process) please call

aws_satella.start_if_not_started(*args, **kwargs) None

Check if exporter thread has been started. If it has not, start it.

Raises

InitializationError – could not initialize AWS Satella exporter

Parameters
  • args – will be passed to AWSSatellaExporterThread’s constructor

  • kwargs – will be passed to AWSSatellaExporterThread’s constructor

This will provide all of it’s arguments to:

class aws_satella.AWSSatellaExporterThread(namespace: str, extra_dimensions: Optional[Dict[str, str]] = None, interval: Union[str, int] = '300s', max_send_at_once: int = 20, add_pid: Optional[str] = None, call_on_metric_upload_fails: Callable[[Exception], None] = <function AWSSatellaExporterThread.<lambda>>, call_on_discarded_metric: Callable[[satella.instrumentation.metrics.data.MetricData], None] = <function AWSSatellaExporterThread.<lambda>>)

A AWS satella exporter thread. Is daemonic, so you don’t need to terminate it when you quit.

Parameters
  • namespace – AWS namespace to use

  • extra_dimensions – extra dimensions to add to sent metrics

  • interval – amount of seconds to wait between sending metrics. Defaults to 5 minutes. Can be also given in a form of expression, like ‘30m’

  • add_pid – If this is set to a string this will add an extra dimension called that and having the value of this process’ PID. This is done to monitor preforking services.

  • max_send_at_once – maximum amount of metrics to send for a single call to AWS. Defaults to 20.

  • call_on_metric_upload_fails – optional callable, to be called with an Exception instance when upload of the metrics fails

  • call_on_discarded_metric – called with a discarded MetricData. Metrics will be discarded for having more than 10 dimensions (after update)

Which in turn may raise an exception during it’s construction, namely:

class aws_satella.InitializationError

Exception raised when boto3 client cannot be configured

If you service preforks, set add_pid argument to, for example pid.

Usage with Django

To use aws-satella with Django, add the following to your :code:`settings.py:

MIDDLEWARE = [
    ...,
    'aws_satella.contrib.django.AWSSatellaMiddleware',
    ...
]

AWS_SATELLA_MIDDLEWARE_CONSTRUCTOR = {
    'namespace': 'YourAppNamespace',
    'add_pid': 'pid'
}

Basically all the parameters here will be passed as kwargs to AWSSatellaExporterThread.

Note that you still need to install and configure django-satella-metrics separately.