Skip to content

Instantly share code, notes, and snippets.

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

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)
measurements = [u"m%s" % (str(n)) for n in xrange(0, 150)]
tags = {}
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__":
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.