Last active
February 8, 2017 21:31
-
-
Save tima/d709da1f88f7e29e0536311f4d9835c2 to your computer and use it in GitHub Desktop.
influxdb/grafana annotation test
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 | |
from influxdb import InfluxDBClient | |
import datetime | |
def annotate(): | |
_host = 'localhost' | |
_port = 8086 | |
_user = "root" | |
_pass = "root" | |
_dbname = 'telegraf' | |
annotation_body = [ | |
{ | |
"measurement": "events", | |
"tags": { | |
"type": "start", | |
"text": "This is the start" | |
}, | |
"time": datetime.datetime.utcnow().isoformat(), | |
"fields": { | |
"value": 1 | |
} | |
} | |
] | |
client = InfluxDBClient(_host, _port, _user, _pass, _dbname) | |
try: | |
client.create_database(_dbname) | |
except: | |
pass | |
client.switch_database(_dbname) | |
client.switch_user(_user, _pass) | |
client.write_points(annotation_body) | |
print annotation_body | |
if __name__ == '__main__': | |
annotate() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment