Improve sf-notifier worker management

- tune uwsgi with feature flags based on
  https://www.bloomberg.com/company/stories/configuring-uwsgi-production-deployment/
- add second HTTP process for redundancy
- increase worker lifetime to 1 hour
- handle Prometheus metrics in multiprocess mode

Change-Id: Ie63333d982fd73791db15eedc0604d0e1f01f34f
Related-PROD: PRODX-34058
3 files changed
tree: d0c226105289d9ec0e2ae62984f6fee1108e7194
  1. sf_notifier/
  2. .dockerignore
  3. .gitignore
  4. .gitreview
  5. _tox.ini
  6. Dockerfile
  7. entrypoint.sh
  8. LICENSE
  9. README.md
  10. requirements.txt
  11. run-func-tests.sh
  12. run-tests.sh
  13. setup.py
  14. test-requirements.txt
  15. tox.ini
README.md

sf-notifier

Prometheus Alertmanager webhook receiver sending alert notification to Salesforce.

Development

Setup

Install Python dependencies:

$ virtualenv venv -p python3
$ source venv/bin/activate
(venv)$ source sf_notifier/vars/development
(venv)$ pip install --upgrade pip
(venv)$ pip install -e .

Add to settings/development.py credentials for your Salesforce customer (not engineering) account:

SF_CONFIG = {
    'AUTH_URL': 'xxx',
    'USERNAME': 'xxx',
    'PASSWORD': 'xxx',
    'ORGANIZATION_ID': 'xxx',
    'ENVIRONMENT_ID': 'xxx',
    'SANDBOX_ENABLED': True
}

You may also specify environment variables to override Python settings:

export SFDC_AUTH_URL="xxx"
export SFDC_USERNAME="xxx"
export SFDC_PASSWORD="xxx"
export SFDC_ORGANIZATION_ID="xxx"
export SFDC_ENVIRONMENT_ID="xxx"
export SFDC_SANDBOX_ENABLED=true

Run server:

(venv)$ uwsgi --http 127.0.0.1:5000 --wsgi-file sf_notifier/server.py --callable app_dispatch

Check in browser:

http://127.0.0.1:5000/metrics