Skip to content

qoneci/notify

Repository files navigation

Notify minimal notifyer

Smal service to send notifications to multiple services like Slack DataDog. currently supported services is Slack, DataDog

written to work in python3.5

configure service

add a .notify.yml

slack:
  orgs:
    - name: foo
      token: xoxp-foobar

datadog:
  orgs:
    - name: foo
      api_key: foo

running api in wsgi container

$ gunicorn notify.app:api

api

GET /health response 200 body: {"status": "OK"}

POST /api/notify body: application/json

{
    "org_name": string,
    "message": string,
    "services": list,
    "channel_name": string,
    "tags": list,               # optional needed for datadog
    "alert_type": string        # optional needed for datadog
}

response: 201

install

$ virtualenv venv
$ source venv/bin/activate
pip3 install -r requirements.txt

example use

first start the server and configure the intergration you like to use. The follwing example will send two events one to slack and one to datadog. for slack it will send it to the qoneci org with the messame foo bar in channel test. For datadog it will send a event with title info message foo bar and alert level info and tags testing:test

$ gunicorn notify.app:api
import json
import requests
body = {
    'org_name': 'qoneci',
    'message': 'foo bar',
    'services': ['slack', 'datadog'],
    'channel_name': 'test',
    'alert_type': 'info',
    'tags': ['testing:test'],
}
url = 'http://127.0.0.1:8000/api/notify'
headers = {'content-type': 'application/json'}

In [9]: requests.post(url, headers=headers, data=json.dumps(body))
Out[9]: <Response [201]>

About

Notify in one call send to many

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published