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 DataDog Terraform generator
- 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
- 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 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
- source the venv that the application runs in
- python monitor_generator.py ../test-app/app:app
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 App Object API: https://tedboy.github.io/flask/interface_api.application_object.html
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
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1cec5b7d8341047ed6aa4b6f9da5e6971924e36615478b922b4ac2afe20ff28d |
|
MD5 | 19675462d857b6b83de6224d472eb273 |
|
BLAKE2b-256 | 56904f458085f50051a3860cf3f0533d901b2f296a4d69c336d18fdd42cd438c |
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 939e3ce2dfbb9cd416e2c7beb36fde94ee1adaa729d763191c8af22864e615ab |
|
MD5 | a505ed20e21c4db68197e66a8adf5112 |
|
BLAKE2b-256 | 3a2ff17d92bf364fb5c6f164dcf8d9f47769bfff7ba524becc413e41dfd8c108 |