-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
99e3007
commit 569cabf
Showing
4 changed files
with
30 additions
and
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
init: | ||
pip install -r requirements.txt | ||
|
||
bundle: | ||
zip kapacitor-teams-handler.zip \ | ||
README.md \ | ||
|
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,45 +1,34 @@ | ||
# Python MS Teams API for Kapacitor Alerts | ||
A respective setting already exists in the [kapacitor configuration](https://docs.influxdata.com/kapacitor/v1.5/event_handlers/microsoftteams/). | ||
|
||
Please note that kapacitor natively provides an [event handler](https://docs.influxdata.com/kapacitor/v1.5/event_handlers/microsoftteams/) for MS Teams. | ||
This project is for greater flexibility in relation to proxies and was developed for the Alerting UI in the **inspectIT Ocelot - Configuration Server** [Project](https://github.com/inspectIT/inspectit-ocelot/tree/master/components/inspectit-ocelot-configurationserver). | ||
|
||
## Installation | ||
Install all dependencies. | ||
|
||
```bash | ||
pip install -r requirements.txt | ||
``` | ||
|
||
## Usage | ||
### Bundle | ||
Create a zip file with all required files: | ||
```bash | ||
make bundle | ||
``` | ||
Create a "/teams-api" directory under the kapacitor load directory (default: /etc/kapacitor/load/handler_scripts), copy and unzip the created zip file there. | ||
One or more handlers can be created under the /etc/kapacitor/load/handlers directory. | ||
|
||
Optional: Edit the [configurations](configuration) | ||
|
||
Example "teams-handler-team1.yml": | ||
* Download the [kapacitor-teams-handler.zip](https://github.com/NovatecConsulting/kapacitor-ms-teams-handler/releases) | ||
from the latest Release or create a zip file with all required files with `make bundle` | ||
* Create a "handler script" directory, copy and unzip the ZIP file there. *For example under the kapacitor load directory: | ||
`/etc/kapacitor/load/handler_scripts/teams-api`.* | ||
This path is required later in the handler-files. | ||
* Navigate to the handler script path and install all dependencies: `pip3 install -r requirements.txt` | ||
* To use the MS Teams handler, create one or more handler-files `<custom_name>.yml` under the `/etc/kapacitor/load/handlers` directory. | ||
* Edit the [configurations](configuration) to your specifications *(log path and proxy settings)*. | ||
|
||
### Handler-file example | ||
```yml | ||
id: ms_teams-issue-handler_team_1 | ||
topic: ms_teams_team_1 | ||
# /etc/kapacitor/load/handlers/teams-handler-team1.yml | ||
id: ms_teams-issue-handler_team_1 # handler id in the Ocelot - Configuration Server UI | ||
topic: ms_teams_team_1 # channel in the Ocelot - Configuration Server UI | ||
kind: exec | ||
options: | ||
prog: '/usr/bin/python3' | ||
prog: '/usr/bin/python3' # path to python3 | ||
args: | ||
- '/etc/kapacitor/load/handler_scripts/teams-api/main.py' # python file path (required) | ||
- 'https://outlook.office.com/webhook/xxx' # webhook (required) | ||
- '/etc/kapacitor/load/handler_scripts/teams-api/main.py' # entrypoint path (required) | ||
- 'https://outlook.office.com/webhook/xxx' # webhook (required) | ||
``` | ||
This handler will be visible on the inspectIT Ocelot - Configuration Server UI, if the Alerting settings are enabled. | ||
Note that the entrypoint path must be refer to the previous unzipped directory. | ||
The handlers are visible on the inspectIT Ocelot - Configuration Server UI. | ||
### Config | ||
The Log Path can be edited in the [configuration.py](configuration/configuration.py) file. | ||
The log path and proxy URLs can be edited in the [configuration.py](configuration/configuration.py) file. | ||
### Testing | ||
The Script can be tested with the [example.json](tests/example_alert.json) file: | ||
```bash | ||
# root folder: | ||
python3 main.py "https://webhook-url" < tests/example_alert.json | ||
``` | ||
The script can be tested with the [example.json](tests/example_alert.json) file: `python3 main.py "https://webhook-url" < tests/example_alert.json` |
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