Created
March 21, 2016 03:18
-
-
Save laughingman7743/018798da69eb08a1e2a3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from __future__ import print_function | |
import json | |
import requests | |
SLACK_API = 'https://slack.com/api/' | |
SLACK_API_METHOD = 'chat.postMessage' | |
SLACK_TOKEN = 'YOUR_TOKEN' | |
SLACK_CHANNEL = '#YOUR_CHANNEL' | |
SLACK_ICON_URL = 'http://YOUR_ICON_URL' | |
def main(): | |
response = requests.post(SLACK_API + SLACK_API_METHOD, data={ | |
'token': SLACK_TOKEN, | |
'channel': SLACK_CHANNEL, | |
'icon_url': SLACK_ICON_URL, | |
'username': 'Datadog', | |
"attachments": json.dumps([ | |
{ | |
"fallback": "Network traffic (kb/s): How does this look? @slack-ops - Sent by Julie Dodd - https://datadog.com/path/to/event", | |
"title": "Network traffic (kb/s)", | |
"title_link": "https://datadog.com/path/to/event", | |
"text": "How does this look? @slack-ops - Sent by Julie Dodd", | |
"image_url": "https://datadoghq.com/snapshot/path/to/snapshot.png", | |
"color": "#764FA5" | |
} | |
]) | |
}).json() | |
print(response) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment