Created
May 5, 2017 11:35
-
-
Save oprietop/06972ac15a395f9e903b405aebd1631e to your computer and use it in GitHub Desktop.
Trying the graphite events api
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
#! /usr/bin/python | |
# -*- coding: utf8 -*- | |
# http://graphite.readthedocs.io/en/latest/events.html | |
import time | |
import requests | |
host = "http://graphite/events/" | |
epoch = int(time.time()) | |
now = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(epoch)) | |
print(epoch) | |
print(now) | |
json_data = { "what": "Testing graphite events api" | |
, "tags": "test,epoch,events" | |
, "when": epoch # Not mandatory | |
, "data": "Testing the graphite events api at " + now | |
} | |
print('# Post event') | |
r = requests.post(host, json=json_data) | |
print(r.status_code) | |
print(r.text) | |
print('# Get events') | |
r = requests.get(host + "/get_data?tags=test epoch events&from=-5min&until=now") | |
print(r.status_code) | |
print(r.json()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment