I'm prepending the Unix epoch with "nanosecond" precision into output of my command as below:
$ command | while read line; do d=`date +%s%N`; echo $d $line; done > file
I looked around to find out how to turn "nanosecond" into "millisecond". For example, I followed the solution given here. So, I tried both suggested approaches:
$ command | while read line; do d=`echo $(($(date +%s%N)/1000000))`; echo $d $line; done > file
$ command | while read line; do d=`date +%s%N | cut -b1-13`; echo $d $line; done > file
However, in both cases when I insert the file into InfluxDB and query my database I get this:
time
1970-01-01T00:24:05.419982325Z
1970-01-01T00:24:05.419982344Z
1970-01-01T00:24:05.419982371Z
1970-01-01T00:24:05.419982378Z
1970-01-01T00:24:05.419982388Z
1970-01-01T00:24:05.419982401Z
Update
When I use epoch with nanosecond accuracy date +%s%N
, I get this:
time
2015-10-21T08:59:59.978902683Z
2015-10-21T08:59:59.982615836Z
2015-10-21T08:59:59.983958069Z
2015-10-21T08:59:59.98805317Z
2015-10-21T08:59:59.99717678Z
2015-10-21T09:00:00.028624495Z
I'm expecting such an output:
2015-10-21T09:12:10.001327Z
Please let me know if you have any solution.
u
suffix to the number so it is recognised by InfluxDB as an absolute time, egecho ${d}u $line
.