Skip to main content

Tool for auto generating DataDog Monitors from flask endpoints

Project description

Overview

Utility for auto generating DataDog terraform monitor specifications from flask endpoints.

  1. Setup DataDog Terraform integration
  2. Decorate flask endpoints you want to monitor
  3. Run the DataDog Terraform generator
  4. Apply Terraform changes

Decorator Examples

# Decorating with `datadog_monitors` will generate default monitors for each
# method on the route
@datadog_monitors()
@flask_app.route('/foo', methods=['GET', 'POST'])
def handle_foo():
    return ''

# Specifying a specific monitor will only generate that monitor for each
# method on the route
@datadog_monitors(
    monitors={
        MonitorType.APM_ERROR_RATE_THRESHOLD: {
            MonitorSpec.CRITICAL_THRESHOLD: 0.8,
            MonitorSpec.ALERT_PERIOD: '10m',
        },
    },
)
@flask_app.route('/foo', methods=['GET', 'POST'])
def handle_foo():
    return ''

Running

Running the test app service against a test DataDog account

Assumptions

  • Test DataDog account is created; API and APP key are known

Running

  1. Set DATADOG_API_KEY in env vars
  2. Set DATADOG_APP_KEY in env vars
  3. make sync-datadog: this applies monitoring configs to datadog acnt
  4. make local-up: this builds app and dd-agent containers and runs them locally

Local setup

  • Local docker compose environment runs test server in editable mode so you can modify python files while testing.

Running auto terraform generator

Running

  1. source the venv that the application runs in
  2. python monitor_generator.py ../test-app/app:app

Testing

  1. Ensure venv is created. From root dir: python -m venv venv
  2. Install testing dependencies: ./venv/bin/pip install .[testing] (setup.cfg has testing extras_require)
  3. make test

Reference

TODO

  • TF generation needs to be an executable
  • Allow specification of just the monitors you want to default to
  • "trigger when metric is <above/below> the threshold <in total | on average | etc.> ...
  • test with different versions of Flask
  • make terraform file generator into a cmd line executable

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flask-datadog-monitor-0.0.6.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

flask_datadog_monitor-0.0.6-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file flask-datadog-monitor-0.0.6.tar.gz.

File metadata

  • Download URL: flask-datadog-monitor-0.0.6.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.1

File hashes

Hashes for flask-datadog-monitor-0.0.6.tar.gz
Algorithm Hash digest
SHA256 1cec5b7d8341047ed6aa4b6f9da5e6971924e36615478b922b4ac2afe20ff28d
MD5 19675462d857b6b83de6224d472eb273
BLAKE2b-256 56904f458085f50051a3860cf3f0533d901b2f296a4d69c336d18fdd42cd438c

See more details on using hashes here.

File details

Details for the file flask_datadog_monitor-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: flask_datadog_monitor-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.1

File hashes

Hashes for flask_datadog_monitor-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 939e3ce2dfbb9cd416e2c7beb36fde94ee1adaa729d763191c8af22864e615ab
MD5 a505ed20e21c4db68197e66a8adf5112
BLAKE2b-256 3a2ff17d92bf364fb5c6f164dcf8d9f47769bfff7ba524becc413e41dfd8c108

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page