我使用以下代码行在influxDB中添加度量数据。
def add_job_influx_db_metrics(tags_dict={}, values_dict={}, measurement='test'):
influxdb_client = InfluxDB.get_connection()
db_name = "mydb"
influxdb_client.switch_database(database=db_name)
current_time = time.strftime('%Y-%m-%dT%H:%M:%SZ',time.localtime(time.time()))
json_body = [
{
"measurement": measurement,
"tags": tags_dict,
"time": current_time,
"fields": values_dict
}
]
response = influxdb_client.write_points(points=json_body)
print "write_operation response", response
当我将它与Grafana集成时,数据不会出现,但当我检查它时,它显示时间是1970-01-01T00:00:00Z。可能它将开始纪元时间作为默认值。 我想花点时间填写表格“2015-8-19T07:15:00Z”。 如何获取infloxdb(python客户端)中的时间字段,什么是时间精度?
您需要UNIX时间戳,因此应该是:
在json-body中使用这样的“time”—
它起作用了。
相关问题 更多 >
编程相关推荐