Flask app, db model, and python ETL for tracking/admin/forecasting of datacenter spend. Additional functionality has been added for capacity and datacenter checks.
The root directory has the WSGI file. I suggest using nginx, with uwsgi-emperor running flask app as vassals.
/misc has the MySQL db model for the dubwebdb. After creating the database:
- Populate the providers table, using one row per unique billing provider.
- Populate the teams table, using one row per logical team/unit.
- Populate the projects table, assigning the team and provider to the project. Note: projects span neither teams nor providers.
- Populate the budgets table; assign monthly budget for each team's provider.
- After initial provisioning, you may use the admin pages for modifying teams, projects, and budgets.
- You may decide to use the matchrules.csv for characterizing workloads
/etl has the python ETL that will pull the data as instructed by the files in the /etl/zu directory. To start collecting data:
Modify zu_advanced_meta.json
to set DB parameters, metricstypes.
Create a metricstypes file for each separate billing provider:
- Use the
zu_*_metrics.json
file for the specific type of billing source data given by the billing provider. e.g., Google provides json. - Modify the permetric value, if desired, used in eval for providing:
- Provider's start time (beginning of day/month metric covers).
- Provider's project number
- Provider's measurement id
- Provider's metric measurement (e.g., 24 ) (device/hours)
- Provider's metric untis (e.g., device/hours)
- Provider's cost for given product described by metric.
- Add a "various" list entry for each daily metric that needs all instance metrics for the calculation, but isn't provided by provider (e.g., Tax):
- Metric name
- Provider's start time.
- Metric id
- Project id
- Project name
- Metric formula (taxrate is passed into processing function)
- Team id
- Copying the provider(s) data file(s) into the zu subdirectory.
- Loading the data into the DB using:
python cub_extract -f zu/zu_advanced_meta.json
- Ensuring that cloning is enabled in the .admin_settings file.
- Calling the /misc/clone_month.sh file (after setting your basic auth creds).
/app has the flask app. To personalize for your billing needs:
- Modify the .*settings files (templates in /misc): 1. Move the file to a durable location accessible to uwsgi-emperor/nginx 2. Modify the file to match your DB parameters. 3. I suggest using different settings files for the different sets of functionality, as the dubwebdb.py functionality only requires SELECT mysql privileges.
- Add a new measurement API and chart pair by: 1. Adding data retrieval function for API to dubwebdb.py. 2. Add API route to apis.py. 3. Add template for new measurement/chart in templates, calling new API. 4. Add chart route to views.py
/tests has the python unittests:
- Tests for the python modules can be run using nosetests, for example:
nosetests `tests/test_dubwebdb.py`
The project uses the following applications (installed via apt-get, on Ubuntu):
- nginx
- uwsgi_emperor
The project uses the following python packages (installed via pip):
- virtualenv
- Flask
- mysql-python
- python-dateutil
- numpy
- pyfscache
- simplejson
- requests
- functools