def output_influxdb(self):
""" Writes data to the InfluxDB """
client = InfluxDBClient(self.db_host, self.db_port, self.db_user, self.db_password, self.db_name)
# TODO: Refactor to batch to optimize writes to the DB
for data in self.data_list:
measurement = data['command']
# Build JSON body for the REST API call
json_body = [
{
'measurement': measurement,
'tags': data['tag'],
'fields': data['fields'],
'time': data['timestamp']
}
]
client.write_points(json_body, time_precision='s')
评论列表
文章目录