Skip to content

Instantly share code, notes, and snippets.

@pkittenis pkittenis/cpu_usage.png
Last active Feb 9, 2017

Embed
What would you like to do?
InfluxGraph graphs
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
You can’t perform that action at this time.