Feature: support HipChat Server

This commit is contained in:
nao-akechi 2016-01-15 18:36:07 +09:00
parent f4096c0356
commit fac0af548b
2 changed files with 5 additions and 1 deletions

View File

@ -110,6 +110,7 @@ MAIL_ASCII_ATTACHMENTS = parse_boolean(os.environ.get('REDASH_MAIL_ASCII_ATTACHM
HOST = os.environ.get('REDASH_HOST', '')
HIPCHAT_API_TOKEN = os.environ.get('REDASH_HIPCHAT_API_TOKEN', None)
HIPCHAT_API_URL = os.environ.get('REDASH_HIPCHAT_API_URL', None)
HIPCHAT_ROOM_ID = os.environ.get('REDASH_HIPCHAT_ROOM_ID', None)
WEBHOOK_ENDPOINT = os.environ.get('REDASH_WEBHOOK_ENDPOINT', None)

View File

@ -349,7 +349,10 @@ def check_alerts_for_query(self, query_id):
def notify_hipchat(alert, html, new_state):
try:
hipchat_client = hipchat.HipChat(token=settings.HIPCHAT_API_TOKEN)
if settings.HIPCHAT_API_URL:
hipchat_client = hipchat.HipChat(token=settings.HIPCHAT_API_TOKEN, url=settings.HIPCHAT_API_URL)
else:
hipchat_client = hipchat.HipChat(token=settings.HIPCHAT_API_TOKEN)
message = '[' + new_state.upper() + '] ' + alert.name + '<br />' + html
hipchat_client.message_room(settings.HIPCHAT_ROOM_ID, settings.NAME, message.encode('utf-8', 'ignore'), message_format='html')
except Exception: