influxdb-python
influxdb-python copied to clipboard
Enable serialisation of SeriesHelper data points
We're introducing InfluxDB reporting in to a batch job pipeline we have. However, we don't want to introduce a runtime dependency on our InfluxDB server (as it's only intended for rough metric tracking, so doesn't have an SLA from the team that run it).
It would be good if there were a supported way of serialising all the data point that a SeriesHelper class has been given in the public API; we could write these out and have a separate job (whose failure wouldn't block our broader pipeline) read them in and write them to InfluxDB.
Currently, I think we can do this by calling the ._json_body_()
method, and writing the result out to disk. Really, I think all I'm asking is that this is moved in to the public API, so I can worry a bit less about it disappearing in future.
Digging in to this a bit further, the dict returned by _json_body_
isn't actually JSON-serialisable because it contains a datetime
object.
So maybe something like a new .to_json()
or .points_as_json()
method which returns a JSON string with the datetime
converted to something that will round-trip would make more sense?
There's also the question of resetting the series; I wouldn't expect this new method to do so, but people might want it. Perhaps something like .commit_to_file(f)
which would do the reset?
(We'd only call this once at the end of a batch job, so it doesn't really affect us.)
Thanks for reporting this @OddBloke, not really sure what that'll buy you if we have another function to split the data back as a pure JSON
blob but if you're up for the challenge we'd love to see a PR on this?
Is this blocking your usage of the system right now?