25 lines
848 B
Python
25 lines
848 B
Python
import influxdb_client
|
|
from influxdb_client import InfluxDBClient, Point, WritePrecision
|
|
from influxdb_client.client.write_api import SYNCHRONOUS
|
|
import os
|
|
|
|
#token = os.environ.get("dQV0BbJvy7W9Bool6FGh1ryb_uXBNqZB8BlJqb8yC4yNB8RTDSooT5hixoqMf8cBeXUXTRUdmkwlxnkI9PCsBA==")
|
|
token = os.environ.get("sySU58aCfMdTGtBTttduzSS_x_4CBI1twpicYw4Idq9abZWGsAXdbvww2wWmwmLDTtrALAx4Q0wZK9PUIr4ejg==")
|
|
org = "gbucchino"
|
|
url = "http://192.168.1.68:8086"
|
|
|
|
write_client = influxdb_client.InfluxDBClient(url=url, token=token, org=org)
|
|
|
|
bucket="tcp"
|
|
|
|
write_api = write_client.write_api(write_options=SYNCHRONOUS)
|
|
|
|
for value in range(5):
|
|
point = (
|
|
Point("measurement1")
|
|
.tag("tagname1", "tagvalue1")
|
|
.field("field1", value)
|
|
)
|
|
write_api.write(bucket=bucket, org="gbucchino", record=point)
|
|
time.sleep(1) # separate points by 1 second
|