Tool for auto generating DataDog Monitors from flask endpoints
Project description
Overview
Utility for auto generating DataDog terraform monitor specifications from flask endpoints.
- Setup DataDog Terraform integration
- Decorate flask endpoints you want to monitor
- Run the
flask-datadog
cmd line util to generate terraform files for the monitors - Apply Terraform changes
Usage Examples
Decorate Flask endpoints you want to monitor
# 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 particular monitor will allow you to tweak thresholds (and
# other parameters) but will only generate that particular monitor for
# that 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 ''
Generate Terraform for monitors with cmd line utility
flask-datadog gen-terraform --env prod --service my_service path/to/flask_app:app output_dir
Running This Project Locally
Info on running the test service locally against a DataDog test account.
Assumptions
- You have a DataDog test account created
Steps to standup local test env
- Set DATADOG_API_KEY in env vars
- Set DATADOG_APP_KEY in env vars
make sync-datadog
: this applies monitoring configs to datadog acntmake local-up
: this builds app and runs them locally with the dd-agent containers
Once the local env is up, an automatic script in the fake-client
service
should ping the test-app
service periodically to generate fake traffic.
The test-app
service and fake-client
service both have mount points so
you can edit the code and have changes reflected directly without rebuilding
containers.
Unit / Integration Testing
- Ensure venv is created. From root dir:
python -m venv venv
- Install testing dependencies:
./venv/bin/pip install .[testing]
(setup.cfg hastesting
extras_require) make test
Reference
Flask API interface
- Flask App Object API: https://tedboy.github.io/flask/interface_api.application_object.html
TODO
- 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
Built Distribution
File details
Details for the file flask-datadog-monitor-0.0.7.tar.gz
.
File metadata
- Download URL: flask-datadog-monitor-0.0.7.tar.gz
- Upload date:
- Size: 4.2 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 750eb9a7b68e916d7dc55c0555eeb8132837254a6311b63cb4ddbff6f14431c2 |
|
MD5 | a4460bceb96d2ecd6bc80cdefe925c07 |
|
BLAKE2b-256 | 66be9a3a59194de8429824ff49b0c9e41475ab2bc81985e5833a50e3629078ee |
File details
Details for the file flask_datadog_monitor-0.0.7-py3-none-any.whl
.
File metadata
- Download URL: flask_datadog_monitor-0.0.7-py3-none-any.whl
- Upload date:
- Size: 5.0 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | c842f516573d2a15ac9b82be63d75935057144a4d09ec2b02fc4569e37ede96b |
|
MD5 | b12c7db0a00bb7f335314f7747de22c0 |
|
BLAKE2b-256 | 39ed174ef58180ed02d610a2f56161b4efec2bd54ed34d9dac532e0012cadafa |