Issue
As a beginner, I tried example-like commands on official docs with a victoria-metrics in docker container.
While I try to write and read to verify whether my operation succeeded, I found it curious: I can only write with mil-sec
time unit, while I can only query with second
time unit.
How could it be possible that I need to handle different time unit for ingest and query ?
DId I miss any detail about using step
in a decent way?
Any helo would be sincerely appreciated.
Commands I tried:
// try 1: write with mil-sec
// write
curl -d '{"metric":{"__name__":"zoo2","job":"node_exporter"},"values":[0,1,2],"timestamps":[1686207845001,1686207846002,1686207848003]}' -X POST 'http://localhost:8428/api/v1/import'
// no
curl "http://localhost:8428/api/v1/query_range?query=zoo2&start=1686207845000&end=1686207850000&step=1"
// yes
curl "http://localhost:8428/api/v1/query_range?query=zoo2&start=1686207845&end=1686207850&step=1"
// try 2: write with sec
curl -d '{"metric":{"__name__":"zoo3","job":"node_exporter"},"values":[0,1,2],"timestamps":[1686207845,1686207846,1686207848]}' -X POST 'http://localhost:8428/api/v1/import'
// no
curl "http://localhost:8428/api/v1/query_range?query=zoo3&start=1686207845000&end=1686207850000&step=1"
// no, either
curl "http://localhost:8428/api/v1/query_range?query=zoo3&start=1686207845&end=1686207850&step=1"
Solution
That's the wrong format for specifying milliseconds - see https://docs.victoriametrics.com/Single-server-VictoriaMetrics.html#timestamp-formats. Try the following:
curl "http://localhost:8428/api/v1/query_range?query=zoo2&start=1686207845.000&end=168620785.000&step=1"
I've added PR to make units format more clear in docs - https://github.com/VictoriaMetrics/VictoriaMetrics/pull/4428/files
Update: VictoriaMetrics supports specifying timestamps in milliseconds in start
, end
and time
query args starting from v1.92.0. For example, the following query is equivalent to the query above starting from v1.92.0
:
curl "http://localhost:8428/api/v1/query_range?query=zoo2&start=1686207845000&end=168620785000&step=1"
Answered By - hagen1778 Answer Checked By - Senaida (WPSolving Volunteer)