Last active
February 9, 2017 17:15
-
-
Save pkittenis/767dafb970bbc53d80e58ad5fbbab755 to your computer and use it in GitHub Desktop.
InfluxGraph graphs
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
from influxdb import InfluxDBClient | |
import datetime | |
def write_data(client, measurements, tags, fields): | |
end_time = datetime.datetime.utcnow() | |
data = [{ | |
"measurement": measurement, | |
"tags": tags, | |
"time": _time, | |
"fields": fields, | |
} | |
for measurement in measurements | |
for _time in [ | |
(end_time - datetime.timedelta(minutes=30)).strftime("%Y-%m-%dT%H:%M:%SZ"), | |
(end_time - datetime.timedelta(minutes=2)).strftime("%Y-%m-%dT%H:%M:%SZ"), | |
]] | |
assert(client.write_points(data) == True) | |
def write_field_keys(db='field_keys_test'): | |
client = InfluxDBClient(database=db) | |
client.create_database(db) | |
measurements = [u"m%s" % (str(n)) for n in xrange(0, 150)] | |
tags = {} | |
client.drop_database(db) | |
client.create_database(db) | |
for i, measurement in enumerate(measurements): | |
_fields = {'f%s' % (str(f),): 1 for f in xrange(0, i+1)} | |
write_data(client, [measurement], tags, _fields) | |
if __name__ == "__main__": | |
write_field_keys() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment