Skip to content

Commit

Permalink
#53 Fix prom2teams uwsgi bin startup
Browse files Browse the repository at this point in the history
  • Loading branch information
jmonterrubio committed Mar 1, 2018
1 parent a5b5c11 commit bd308df
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a changelog](https://github.com/olivierlacan/keep-a-changelog).

## [Unreleased](https://github.com/idealista/prom2teams/tree/develop)
### Fixed
- *[#53](https://github.com/idealista/prom2teams/issues/53) Fix prom2teams uwsgi bin startup* @jmonterrubio

## [2.0.0](https://github.com/idealista/prom2teams/tree/2.0.0)
[Full Changelog](https://github.com/idealista/prom2teams/compare/1.3.0...2.0.0)
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
include README.md
include LICENSE
include requirements.txt
include bin/wsgi.py
include */config/*
recursive-include */resources/ *
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# prom2teams

<img src="assets/example.png" alt="Alert example" style="width: 600px;"/>
<img src="https://raw.githubusercontent.com/idealista/prom2teams/master/assets/example.png" alt="Alert example" style="width: 600px;"/>

**prom2teams** is a Web server built with Python that receives alert notifications from a previously configured [Prometheus Alertmanager](https://github.com/prometheus/alertmanager) instance and forwards it to [Microsoft Teams](https://teams.microsoft.com/) using defined connectors.

Expand Down Expand Up @@ -59,7 +59,13 @@ export APP_CONFIG_FILE=<config file path>
$ prom2teams
```

For production environments you should prefer using a WSGI server. You can launch instead:
### Production

For production environments you should prefer using a WSGI server. [uWSGI](https://uwsgi-docs.readthedocs.io/en/latest/)
dependency is installed for an easy usage. Some considerations must be taken to use it:

The binary `prom2teams_uwsgi` launches the app using the uwsgi server. Due to some incompatibilities with [wheel](https://github.com/pypa/wheel)
you must install `prom2teams` using `sudo pip install --no-binary :all: prom2teams` (https://github.com/pypa/wheel/issues/92)

```bash
$ prom2teams_uwsgi <path to uwsgi ini config>
Expand All @@ -82,6 +88,10 @@ env = APP_CONFIG_FILE=/etc/default/prom2teams.ini

Consider not provide `chdir` property neither `module` property.

Also you can set the `module` file, by doing a symbolic link: `sudo mkdir -p /usr/local/etc/prom2teams/ && sudo ln -sf /usr/local/lib/python3.5/dist-packages/usr/local/etc/prom2teams/wsgi.py /usr/local/etc/prom2teams/wsgi.py` (check your dist-packages folder)

Another approach is to provide yourself the `module` file [module example](bin/wsgi.py) and the `bin` uwsgi call [uwsgi example](bin/prom2teams_uwsgi)

**Note:** default log level is DEBUG. Messages are redirected to stdout. To enable file log, set the env APP_ENVIRONMENT=(pro|pre)


Expand All @@ -92,7 +102,7 @@ The config file is an [INI file](https://docs.python.org/3/library/configparser.
```
[Microsoft Teams]
# At least one connector is required here
Connector: <webhook url>
Connector: <webhook url>
AnotherConnector: <webhook url>
...
Expand Down Expand Up @@ -134,11 +144,11 @@ Other optional fields are skipped and not included in the Teams message.

Accessing to `<Host>:<Port>` (e.g. `localhost:8001`) in a web browser shows the API v1 documentation.

<img src="assets/swagger_v1.png" alt="Swagger UI" style="width: 600px;"/>
<img src="https://raw.githubusercontent.com/idealista/prom2teams/master/assets/swagger_v1.png" alt="Swagger UI" style="width: 600px;"/>

Accessing to `<Host>:<Port>/v2` (e.g. `localhost:8001/v2`) in a web browser shows the API v2 documentation.

<img src="assets/swagger_v2.png" alt="Swagger UI" style="width: 600px;"/>
<img src="https://raw.githubusercontent.com/idealista/prom2teams/master/assets/swagger_v2.png" alt="Swagger UI" style="width: 600px;"/>

## Testing

Expand Down
2 changes: 1 addition & 1 deletion bin/prom2teams_uwsgi
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ else
exit 1
fi

uwsgi $config --chdir `dirname "$0"` --module wsgi
uwsgi $config --chdir /usr/local/etc/prom2teams --module wsgi
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def read_requirements_file():


setup(name='prom2teams',
version='2.0.0',
version='2.0.1',
description='Project that redirects Prometheus Alert Manager '
'notifications to Microsoft Teams',
long_description=readme,
Expand All @@ -41,6 +41,9 @@ def read_requirements_file():
'': ['*.ini', '*.j2'],
},
include_package_data=True,
data_files=[
('/usr/local/etc/prom2teams', ['bin/wsgi.py'])
],
url='http://github.com/idealista/prom2teams',
author='Idealista, S.A.U',
author_email='labs@idealista.com',
Expand Down

0 comments on commit bd308df

Please sign in to comment.