-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from idealista/develop
Develop
- Loading branch information
Showing
57 changed files
with
827 additions
and
358 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
include README.md | ||
include LICENSE | ||
include requirements.txt | ||
include config.ini | ||
include logging_console_config.ini | ||
include logging_file_config.ini | ||
include prom2teams/teams/template.j2 | ||
include */config/* | ||
recursive-include */resources/ * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,14 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import sys | ||
import os | ||
import argparse | ||
|
||
|
||
try: | ||
from prom2teams.server import run | ||
from prom2teams.app.api import app as application | ||
except ImportError: | ||
sys.path.append(os.path.abspath('./')) | ||
from prom2teams.server import run | ||
from prom2teams.app.api import app as application | ||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser(description='Receives alert notifications ' | ||
'from Prometheus Alertmanager ' | ||
'(https://github.com/prometheus/alertmanager) ' | ||
'and sends it to Microsoft Teams using configured connectors ') | ||
|
||
parser.add_argument('-c', '--configpath', help='config INI file path', required=True) | ||
parser.add_argument('-l', '--logfilepath', help='log file path', required=False) | ||
parser.add_argument('-v', '--loglevel', help='log level', required=False, default='INFO') | ||
parser.add_argument('-t', '--templatepath', help='Jinja2 template file path', required=False) | ||
|
||
args = parser.parse_args() | ||
|
||
run(args.configpath, args.templatepath, args.logfilepath, args.loglevel) | ||
_host, _port = application.config['SERVER_NAME'].split(':', 1) | ||
application.run(host=_host, port=int(_port)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
if [[ -n $1 ]]; then | ||
config=$1 | ||
else | ||
echo "Provide a uwsgi ini file (without module and chdir flag)" | ||
exit 1 | ||
fi | ||
|
||
uwsgi $config --chdir `dirname "$0"` --module wsgi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import sys | ||
import os | ||
|
||
|
||
try: | ||
from prom2teams.app.api import app as application | ||
except ImportError: | ||
sys.path.append(os.path.abspath('./')) | ||
from prom2teams.app.api import app as application | ||
|
||
|
||
if __name__ == "__main__": | ||
application.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM python:3.5-slim-jessie | ||
|
||
LABEL maintainer="[email protected]" | ||
|
||
EXPOSE 8089 | ||
|
||
RUN pip install prom2teams | ||
COPY config.ini /opt/prom2teams/config.ini | ||
COPY prom2teams_start.sh /opt/prom2teams/prom2teams_start.sh | ||
COPY replace_config.py /opt/prom2teams/replace_config.py | ||
|
||
ENV PROM2TEAMS_PORT="8089" | ||
ENV PROM2TEAMS_HOST="0.0.0.0" | ||
ENV PROM2TEAMS_LOGLEVEL="INFO" | ||
ENV PROM2TEAMS_CONNECTOR="" | ||
|
||
ENTRYPOINT ["bash", "/opt/prom2teams/prom2teams_start.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[HTTP Server] | ||
Host: prom2teamshost | ||
Port: prom2teamsport | ||
|
||
[Microsoft Teams] | ||
Connector: prom2teamsconnector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
python /opt/prom2teams/replace_config.py | ||
prom2teams --configpath /opt/prom2teams/config.ini --loglevel $PROM2TEAMS_LOGLEVEL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env python | ||
import os | ||
|
||
with open('/opt/prom2teams/config.ini', 'r') as file: | ||
filedata = file.read() | ||
|
||
filedata = filedata.replace("prom2teamsport", os.environ.get("PROM2TEAMS_PORT")) | ||
filedata = filedata.replace("prom2teamshost", os.environ.get("PROM2TEAMS_HOST")) | ||
filedata = filedata.replace("prom2teamsconnector", os.environ.get("PROM2TEAMS_CONNECTOR")) | ||
|
||
with open('/opt/prom2teams/config.ini', 'w') as file: | ||
file.write(filedata) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import os | ||
|
||
root = os.path.abspath(os.path.dirname(__file__)) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import logging.config | ||
|
||
from flask import Flask, Blueprint | ||
|
||
from prom2teams.app.configuration import config_app, setup_logging | ||
from .versions.v1 import api_v1 | ||
from .versions.v1.namespace import ns as ns_v1 | ||
from .versions.v2 import api_v2 | ||
from .versions.v2.namespace import ns as ns_v2 | ||
|
||
log = logging.getLogger('prom2teams_app') | ||
|
||
app = Flask(__name__) | ||
|
||
|
||
def register_api(application, api, namespace, blueprint): | ||
api.init_app(blueprint) | ||
api.add_namespace(namespace) | ||
application.register_blueprint(blueprint) | ||
|
||
|
||
def init_app(application): | ||
config_app(application) | ||
setup_logging(application) | ||
|
||
blueprint_v1 = Blueprint('api_v1', __name__, url_prefix=application.config['API_V1_URL_PREFIX']) | ||
blueprint_v2 = Blueprint('api_v2', __name__, url_prefix=application.config['API_V2_URL_PREFIX']) | ||
register_api(application, api_v1, ns_v1, blueprint_v1) | ||
register_api(application, api_v2, ns_v2, blueprint_v2) | ||
|
||
|
||
init_app(app) | ||
log.info(app.config['APP_NAME'] + ' started on ' + app.config['SERVER_NAME']) |
Oops, something went wrong.