Skip to content

Instantly share code, notes, and snippets.

@tima
Last active February 8, 2017 21:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tima/d709da1f88f7e29e0536311f4d9835c2 to your computer and use it in GitHub Desktop.
Save tima/d709da1f88f7e29e0536311f4d9835c2 to your computer and use it in GitHub Desktop.
influxdb/grafana annotation test
#!/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