Search code examples
javascriptnode.jsinfluxdb

How to write(nodejs) multiple points having same timestamp in influxdb?


In my nodejs application, I am using influxdb (time series database) to save my log data. I used node-influx to write points in influxdb. But in my case, there are multiple log data which have same timestamp. In that case, only the last data is saved in the db.

I debugged the scripts and found javascript Date only contains milliseconds So in my case, multiple data have same timestamp as they vary on microseconds. So I need a Date format which give me the current date time with microseconds. Or is there any proper way to write multiple points having same timestamp in influxdb?


Solution

  • Influxdb is designed to hold only one point when the conditions(timestamps,measurement,tags) are identical, so you can accomplish this in two different ways:

    1. insert points by different timestamps in js with microsecond(stackoverflow)

    2. try to use different tags when you add multi points with same timestamps (influxdata_writing_data),such as

      api_info,tag=tag1 elapse=0.234 1467085047286(timestamp is optional)
      api_info,tag=tag2 elapse=0.478 1467085047286(timestamp is optional)