Time_precision with write_api

In previous python influxdb client i could specify time_precision with

client.write_points(entry, time_precision='s')

How can i do this with the new influxdb_client module?
using
return write_api.write(“mybucket”, “my org”, influxBulk)
i’m getting an error
HTTP response headers: HTTPHeaderDict({‘Content-Type’: ‘application/json; charset=utf-8’, ‘X-Influxdb-Build’: ‘OSS’, ‘X-Influxdb-Version’: ‘2.1.1’, ‘X-Platform-Error-Code’: ‘unprocessable entity’, ‘Date’: ‘Mon, 10 Jan 2022 18:53:56 GMT’, ‘Content-Length’: ‘137’})
HTTP response body: {“code”:“unprocessable entity”,“message”:“failure writing points to database: partial write: points beyond retention policy dropped=518”}

Thank you in advance)

Below is a fragment of influxBulk batch record passed to write_api:

[
{
“measurement”: “cardSch1”,
“time”: 1641762001,
“tags”: {
“card”: 1,
“node”: “mme-1-1”
},
“fields”: {
“cpubusy”: 1.98,
“cpuidle”: 98.02,
“numproc”: 231,
“memused”: 7582,
“memtotal”: 16384,
“numcpu”: 1,
“cpu0-cpubusy”: 1.98,
“cpu0-cpuidle”: 98.02,
“cpu0-numproc”: 231,
“cpu0-memused”: 7582,
“cpu0-memtotal”: 16384,
“cpu0-name”: “cpu0”,
“cpu0-cpuused-user”: 0.92,
“cpu0-cpuused-sys”: 0.73,
“cpu0-cpuused-io”: 0.3,
“cpu0-cpuused-irq”: 0.03,
“cpu0-cpuused-idle”: 98.02,
“cpu1-cpubusy”: 0.0,
“cpu1-cpuidle”: 0.0,
“cpu1-numproc”: 0
}
},
{
“measurement”: “cardSch17”,
“time”: 1641762001,
“tags”: {
“card”: 1,
“node”: “mme-1-1”
},
“fields”: {
“dinet-rxpkts-curr”: 1.3,
“dinet-txpkts-curr”: 0.83,
“dinet-rxpkts-5minave”: 4.74,
“dinet-txpkts-5minave”: 2.62,
“dinet-rxpkts-15minave”: 4.95,
“dinet-txpkts-15minave”: 2.87,
“dinet-txdrops-curr”: 0.0,
“dinet-txdrops-5minave”: 0.0,
“dinet-txdrops-15minave”: 0.0,
“iftask-errors”: 97.0
}
},

Hi @aserkin,

You can use write_precision parameter:

write_api.write("my-bucket", "my-org", "h2o_feet,location=coyote_creek water_level=2", write_precision=WritePrecision.S)

Regards

1 Like