Skip to content

Commit

Permalink
Merge pull request #133 from idealista/develop
Browse files Browse the repository at this point in the history
v2.4.0 to master
  • Loading branch information
José Noguera authored Aug 14, 2019
2 parents 3f971f8 + 89d2960 commit 7f96e0a
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,6 @@ ENV/

# pypi config file
.pypirc

# Visual Studio Code
.vscode/
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@
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)

## [2.4.0](https://github.com/idealista/prom2teams/tree/2.4.0)
[Full Changelog](https://github.com/idealista/prom2teams/compare/2.3.3...2.4.0)
## Added
- *[#104](https://github.com/idealista/prom2teams/issues/104) Add ability to reload config without restarting* @jnogol @miguel-chacon
- *[#129](https://github.com/idealista/prom2teams/issues/129) Add prometheus_flask_exporter* @jnogol
## Changed
- *[#128](https://github.com/idealista/prom2teams/pull/128) Allow overriding the config file location in Docker by setting the APP_CONFIG_FILE environment variable* @nvx

## [2.3.3](https://github.com/idealista/prom2teams/tree/2.3.3)
[Full Changelog](https://github.com/idealista/prom2teams/compare/2.3.2...2.3.3)
## Fixed
- *[#122](https://github.com/idealista/prom2teams/issues/125) Wrong type in labels_excluded* @miguel-chacon
- *[#125](https://github.com/idealista/prom2teams/issues/125) Wrong type in labels_excluded* @miguel-chacon

## [2.3.2](https://github.com/idealista/prom2teams/tree/2.3.2)
[Full Changelog](https://github.com/idealista/prom2teams/compare/2.3.1...2.3.2)
Expand Down
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ ENV PROM2TEAMS_PORT="8089" \
PROM2TEAMS_HOST="0.0.0.0" \
PROM2TEAMS_LOGLEVEL="INFO" \
PROM2TEAMS_CONNECTOR="" \
PROM2TEAMS_GROUP_ALERTS_BY=""
PROM2TEAMS_GROUP_ALERTS_BY="" \
APP_CONFIG_FILE="/opt/prom2teams/config.ini" \
PROM2TEAMS_PROMETHEUS_METRICS="true"

ENTRYPOINT ["sh", "prom2teams_start.sh"]
ENTRYPOINT ["sh", "prom2teams_start.sh"]
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ $ pip3 install prom2teams
**Important:** Config path must be provided with at least one Microsoft Teams Connector. Check the options to know how you can supply it.

```bash
# To start the server (config file path , group alerts by, log file path, log level and Jinja2 template path are optional arguments):
$ prom2teams [--configpath <config file path>] [--groupalertsby ("name"|"description"|"instance"|"severity"|"summary")] [--logfilepath <log file path>] [--loglevel (DEBUG|INFO|WARNING|ERROR|CRITICAL)] [--templatepath <Jinja2 template file path>]
# To start the server (enable metrics, config file path , group alerts by, log file path, log level and Jinja2 template path are optional arguments):
$ prom2teams [--enablemetrics] [--configpath <config file path>] [--groupalertsby ("name"|"description"|"instance"|"severity"|"summary")] [--logfilepath <log file path>] [--loglevel (DEBUG|INFO|WARNING|ERROR|CRITICAL)] [--templatepath <Jinja2 template file path>]

# To show the help message:
$ prom2teams --help
Expand All @@ -61,6 +61,13 @@ $ prom2teams
```
**Note:** Grouping alerts works since v2.2.1

### Prom2teams Prometheus metrics

Prom2teams uses Flask and, to have the service monitored, we use @rycus66's [Prometheus Flask Exporter](https://github.com/rycus86/prometheus_flask_exporter). This will enable an endpoint in `/metrics` where you could find interesting metrics to monitor such as number of responses with a certain status. To enable this endpoint, just either:

- Use the `--enablemetrics` or `-m` flag when launching prom2teams.
- Set the environment variable `PROM2TEAMS_PROMETHEUS_METRICS=true`.

### Docker image

Every new Prom2teams release, a new Docker image is built in our [Dockerhub](https://hub.docker.com/r/idealista/prom2teams). We strongly recommend you to use the images with the version tag, though it will be possible to use them without it.
Expand Down
6 changes: 4 additions & 2 deletions bin/prom2teams
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
import sys
import os

from werkzeug.serving import run_simple

try:
from prom2teams.app.api import app as application
Expand All @@ -12,4 +12,6 @@ except ImportError:
if __name__ == "__main__":
host = application.config['HOST']
port = int(application.config['PORT'])
application.run(host=host, port=port)
run_simple(hostname=host, port=port, application=application, use_reloader=True,
reloader_type='stat', reloader_interval=5, extra_files=[application.config['APP_CONFIG_FILE']])

2 changes: 1 addition & 1 deletion docker/prom2teams_start.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh
python /opt/prom2teams/replace_config.py
prom2teams --configpath /opt/prom2teams/config.ini --loglevel $PROM2TEAMS_LOGLEVEL
prom2teams --loglevel $PROM2TEAMS_LOGLEVEL
6 changes: 6 additions & 0 deletions prom2teams/app/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def _config_command_line():
parser.add_argument('-v', '--loglevel', help='log level', required=False)
parser.add_argument('-t', '--templatepath', help='Jinja2 template file path', required=False)
parser.add_argument('-s', '--labelsexcluded', help='prometheus custom labels to be ignored', required=False)
parser.add_argument('-m', '--enablemetrics', action='store_true', help='enable Prom2teams Prometheus metrics', required=False)
return parser.parse_args()


Expand Down Expand Up @@ -98,13 +99,15 @@ def config_app(application):
# Load the file specified by the APP_CONFIG_FILE environment variable
# Variables defined here will override those in the default configuration
if 'APP_CONFIG_FILE' in os.environ:
application.config['APP_CONFIG_FILE'] = os.environ.get('APP_CONFIG_FILE')
config_provided = _config_provided(os.getenv('APP_CONFIG_FILE'))
_update_application_configuration(application, config_provided)

# Parse and load command line properties
# Variables defined here will override previous configuration
command_line_args = _config_command_line()
if command_line_args.configpath:
application.config['APP_CONFIG_FILE'] = command_line_args.configpath
config_provided = _config_provided(command_line_args.configpath)
_update_application_configuration(application, config_provided)
if command_line_args.loglevel:
Expand All @@ -115,6 +118,9 @@ def config_app(application):
application.config['TEMPLATE_PATH'] = command_line_args.templatepath
if command_line_args.groupalertsby:
application.config['GROUP_ALERTS_BY'] = command_line_args.groupalertsby
if (command_line_args.enablemetrics or os.environ.get('PROM2TEAMS_PROMETHEUS_METRICS',False)):
from prometheus_flask_exporter import PrometheusMetrics
metrics = PrometheusMetrics(application)

if 'MICROSOFT_TEAMS' not in application.config:
raise MissingConnectorConfigKeyException('missing connector key in config')
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
requests==2.20.1
flask-restplus==0.12.1
marshmallow==3.0.0rc6
jinja2==2.10
jinja2==2.10.1
Flask==1.0.2
pyyaml==3.12
uwsgi==2.0.16
prometheus_flask_exporter==0.9.0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


setup(name='prom2teams',
version='2.3.3',
version='2.4.0',
description='Project that redirects Prometheus Alert Manager '
'notifications to Microsoft Teams',
long_description=readme,
Expand Down

0 comments on commit 7f96e0a

Please sign in to comment.