Created
December 1, 2015 20:31
-
-
Save danilochilene/4a73e40e8a0b62daceb9 to your computer and use it in GitHub Desktop.
Write data to InfluxDB
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 random | |
from time import sleep | |
import sys | |
client = InfluxDBClient('localhost', 8086, 'root', 'root', 'metrics') | |
x = 0 | |
while True: | |
for d in range(0, 300): | |
value = random.randrange(0,100) | |
data = [ | |
{ | |
"measurement": "cpu_load_short", | |
"tags": { | |
"host": "server01", | |
"region": "us-west" | |
}, | |
"fields": { | |
"value": value } | |
} | |
] | |
client.write_points(data) | |
x += 1 | |
sleep(5) | |
if x == 300: | |
print('Done') | |
sys.exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
root@f3e90ce94cf0:~# influx
Visit https://enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring.
Connected to http://localhost:8086 version 0.9.5.1
InfluxDB shell 0.9.5.1
real 5m1.702s
user 0m0.700s
sys 0m0.010s
root@f3e90ce94cf0:~#