Manage Mozilla performance alerts generated by talos.
The production alert_manager server is running on Ubuntu, so this is probably the easiest environment in which to get things running, but other distributions of linux should be fine as well. We use Apache on the production server, but alert_manager will run standalone for testing as well.
alert_manager is best developed inside a Docker container for consistency across platforms and to enable ease of deployment. Instructions on how to get Docker working on your system follow and should be enough to get an alert_manager environment going:
-
Visit Docker and get docker up and running on your system.
-
Add your user to the 'docker' system group. You may need to start a new terminal/session after doing this. Check the output of
docker ps
and if you don't see permissions warnings you should be fine. -
Run the following git clone (specify a directory of your choosing if you like):
git clone https://github.com/jmaher/alert_manager.git
-
Run virtualenv on the git cloned directory to setup the Python virtual environment:
virtualenv alert_manager
-
cd into the name of the directory into which you cloned the git repository
cd alert_manager
-
Activate the virtual environment:
source bin/activate
-
Run make to create your local docker containers:
cd dockerfiles; make all
-
Start the collection of containers!
fig up
-
Visit http://localhost:8080/alerts.html in your browser and you should be all set.
-
Visit Docker and get docker up and running on your system. And ensure that you run the export DOCKER_HOST=... lines when prompted:
export DOCKER_HOST=tcp://192.168.59.103:2375
-
Run the following git clone to a directory of your choosing:
git clone https://github.com/jmaher/alert_manager.git
-
Run virtualenv on the git cloned directory to setup the Python virtual environment:
virtualenv alert_manager
-
cd into the name of the directory into which you cloned the git repository
cd alert_manager
-
Activate the virtual environment:
source bin/activate
-
Run make to create your local docker containers:
cd dockerfiles; make all
-
Start the collection of containers! (Note: maybe you need to install fig by pip install fig before you run it):
fig up
-
Visit http://localhost:8080/alerts.html in your browser, or http://192.168.59.103:8080/alerts.html if localhost doesn't work and you should be all set. One thing need to point out is the IP address you visit is not restricted to "192.168.59.103", just keep it same as your docker environment host(DOCKER_HOST) which been setted in step 1.
Windows based developers will be best served by installing Vagrant and
relying on a shim VM to run Docker. Follow the instructions in the installer until
you reach the vagrant init
section. Instead of doing vagrant init hashicorp/precise32
do:
vagrant init ubuntu/trusty64
From there resume the install process and finish with:
vagrant ssh
Once you have ssh'ed in, follow the Linux based Alert Manager development with Docker instructions.
The Docker development environment relies on using a Python virtual environment for tools and portability across platforms. Ensure that you have Python Pip installed for your platform before proceeding with these instructions.
Windows users can use the following guide. Specifically, get Python installed and then use the get-pip.py installer once Python is working
OSX users can use the built in version of Python as long as Pip is available, or better, install Brew and Python.
Linux users should have Python already installed. Ensure Pip is installed via your package manager and you should be all set.
To enforce Python code style and avoid silly errors in your Python code, you can set up git pre-commit hook, that will run checks on Python code you want to commit.
ln -s ../../pre-commit.sh .git/hooks/pre-commit
In case you won't deal with found errors, you still can commit by issuing:
git commit --no-verify
Alert manager supports environment-based settings. To enable your own development settings you need to:
-
create local_settings/development.py file (just rename template file)
-
populate it with your settings
-
export TARGET_ENVIRONMENT=development
The alert_manager uses a config.ini file to store identification and options. You can create a default config.ini file by running:
python config.py
Change the username and password for the database as required.
You will also either need a subscription to the mozilla.dev.tree-alerts newsgroup, or make use of the sample data packaged in the sample folder.
Database setup and configuration scripts can all be found in tests/resources/scripts
.
There are scripts for scrubbing and extracting the production database, plus
scripts for making a test database.
To create a test database for your dev machine
python tests/resources/scripts/create_db.py
it uses your config.ini file to find AND REPLACE the schema with test data.
The database is populated by an instance of (datazilla-alerts)[https://github.com/klahnakoski/datazilla-alerts], which is a whole other project.