Last active
July 24, 2017 19:07
-
-
Save leandromoreira/9536537 to your computer and use it in GitHub Desktop.
Post event on graphite using python as a client
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
# more about graphite events at http://obfuscurity.com/2014/01/Graphite-Tip-A-Better-Way-to-Store-Events | |
import json | |
import requests | |
def create_graphite_event(event_description, tags): | |
required_data = "Graphite needs SSD!" # I tried withouth data attribute and it didn't work | |
tags_string = " ".join(str(x) for x in tags) # Since you will pass an array but graphite expects multi tags like "a,b,c" or "a b c" | |
event = {"what": event_description, "tags": tags_string, "data": required_data} | |
try: | |
requests.post("http://localhost/events/", data=json.dumps(event), timeout=1) | |
except Exception as e: | |
print 'Error while creating graphite event:', e | |
#usage | |
create_graphite_event("deploy", ["v0.1.2", "angular_introduced", "profile_microservice"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment