Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrying and limiting messages length when sending to teams #226

Merged
merged 9 commits into from
Oct 27, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.7-alpine AS builder
FROM python:3.8-alpine AS builder
WORKDIR /prom2teams
COPY LICENSE \
MANIFEST.in \
Expand All @@ -11,7 +11,7 @@ COPY bin/ bin
RUN apk add gcc libc-dev yaml-dev linux-headers --no-cache \
&& python setup.py bdist_wheel

FROM python:3.7-alpine
FROM python:3.8-alpine
LABEL maintainer="labs@idealista.com"
EXPOSE 8089
WORKDIR /opt/prom2teams
Expand Down
26 changes: 26 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
autopep8 = "*"

[packages]
requests = "==2.20.1"
flask-restplus = "==0.12.1"
marshmallow = "==3.0.0rc6"
prometheus-flask-exporter = "==0.9.0"
deepdiff = "==4.3.0"
zipp = "==1.2.0"
pyrsistent = "==0.16.0"
Jinja2 = "==2.10.1"
Flask = "==1.0.2"
PyYAML = "==5.1"
uWSGI = "==2.0.16"
Werkzeug = "==0.16.1"
MarkupSafe = "==1.1.1"
tenacity = "==6.2.0"

[requires]
python_version = "3.8"
289 changes: 289 additions & 0 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

### Prerequisites

The application has been tested with _Prometheus 2.2.1_, _Python 3.7.0_ and _pip 9.0.1_.
The application has been tested with _Prometheus 2.2.1_, _Python 3.8.0_ and _pip 9.0.1_.

Newer versions of _Prometheus/Python/pip_ should work but could also present issues.

Expand Down Expand Up @@ -188,7 +188,7 @@ Another approach is to provide yourself the `module` file [module example](bin/w

The config file is an [INI file](https://docs.python.org/3/library/configparser.html#supported-ini-file-structure) and should have the structure described below:

```
```ini
[Microsoft Teams]
# At least one connector is required here
Connector: <webhook url>
Expand All @@ -214,6 +214,11 @@ Excluded: <Coma separated list of labels to ignore>

[Annotations]
Excluded: <Comma separated list of annotations to ignore>

blalop marked this conversation as resolved.
Show resolved Hide resolved
[Teams Client]
RetryEnable: <Enables teams client retry policy> # defaults to false
RetryWaitTime: <Wait time between retries> # default: 60 secs
MaxPayload: <Teams client payload limit in bytes> # default: 24KB
```

**Note:** Grouping alerts works since v2.2.0
Expand Down Expand Up @@ -273,7 +278,7 @@ $ ./test.sh
```

## Built With
![Python 3.6.2](https://img.shields.io/badge/Python-3.6.2-green.svg)
![Python 3.8.0](https://img.shields.io/badge/Python-3.8.0-green.svg)
![pip 9.0.1](https://img.shields.io/badge/pip-9.0.1-green.svg)

## Versioning
Expand Down
6 changes: 6 additions & 0 deletions prom2teams/app/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ def _config_command_line():
def _update_application_configuration(application, configuration):
if 'Microsoft Teams' in configuration:
application.config['MICROSOFT_TEAMS'] = configuration['Microsoft Teams']
if 'Microsoft Teams Client' in configuration:
application.config['TEAMS_CLIENT_CONFIG'] = {
'RETRY_ENABLE': configuration.getboolean('Microsoft Teams Client', 'RetryEnable'),
'RETRY_WAIT_TIME': configuration.getint('Microsoft Teams Client', 'RetryWaitTime'),
'MAX_PAYLOAD': configuration.getint('Microsoft Teams Client', 'MaxPayload')
}
if 'Template' in configuration and 'Path' in configuration['Template']:
application.config['TEMPLATE_PATH'] = configuration['Template']['Path']
if 'Log' in configuration and 'Level' in configuration['Log']:
Expand Down
Loading