profile
viewpoint

Ask questionsrollup_candlestick() results

Version: 1.32.7

I have been testing the rollup_candlestick() function to get OHLC values. I've written some data to VictoriaMetrics using the Influx line protocol (raw CURL requests attached). Measurement name: asset. Random price values every 4min.

1580802480 => price=9111.5 1580802720 => price=9341.5 1580802960 => price=9436.5 1580803200 => price=9384.5 (02/04/2020 @ 8:00am) 1580803440 => price=9300.4 1580803680 => price=9287.6 1580803920 => price=9316.2 1580804160 => price=9423.5 1580804400 => price=9574.1 1580804640 => price=9600.9 1580804880 => price=9579.4 1580805120 => price=9624.2 1580805360 => price=9740.5 1580805600 => price=9642.1 1580805840 => price=9500.1 1580806080 => price=9450.2 1580806320 => price=9400.3 1580806560 => price=9350.4 1580806800 => price=9300.5 (02/04/2020 @ 9:00am) 1580807040 => price=9250.6 1580807280 => price=9150.8 1580807520 => price=9100.9 1580807760 => price=9240.5 1580808000 => price=9564.7 1580808240 => price=9532.7 1580808480 => price=9421.7 1580808720 => price=9325.7 1580808960 => price=9514.7 1580809200 => price=9647.7 1580809440 => price=9874.7 1580809680 => price=9742.7 1580809920 => price=9532.7 1580810160 => price=9412.7 1580810400 => price=9117.7 (02/04/2020 @ 10:00am)

I've got OHLC values over the interval from 8:00AM to 10:00AM with resolution of 1hour using the request:

http://127.0.0.1:8428/api/v1/query_range?query=rollup_candlestick(asset_price)&start=1580803200&end=1580810400&step=3600

And I've got the response:

{"status":"success","data":{"resultType":"matrix","result": [ {"metric":{"rollup":"open","tag":"p"}, "values":[[1580803200,"9436.5"],[1580806800,"9300.4"],[1580810400,"9250.6"]]}, {"metric":{"rollup":"high","tag":"p"}, "values":[[1580803200,"9436.5"],[1580806800,"9740.5"],[1580810400,"9874.7"]]}, {"metric":{"rollup":"low","tag":"p"}, "values":[[1580803200,"9384.5"],[1580806800,"9287.6"],[1580810400,"9100.9"]]}, {"metric":{"rollup":"close","tag":"p"}, "values":[[1580803200,"9384.5"],[1580806800,"9300.5"],[1580810400,"9117.7"]]} ] }}

In other words, I've received 3 OHLC candles: [9436.5 9436.5 9384.5 9384.5] for 1580803200 [9300.4 9740.5 9287.6 9300.5] for 1580806800 [9250.6 9874.7 9100.9 9117.7] for 1580810400

The expected result should be in my opinion 2 OHLC candles: [9384.5 9740.5 9287.6 9350.4] for 1580803200 [9300.5 9874.7 9100.9 9412.7] for 1580806800

It seems that VictoriaMetrics has divided data in the following intervals:

1580802960 => price=9436.5 (because of maxSilenceInterval constant) 1580803200 => price=9384.5 (02/04/2020 @ 8:00am)

1580803440 => price=9300.4 1580803680 => price=9287.6 1580803920 => price=9316.2 1580804160 => price=9423.5 1580804400 => price=9574.1 1580804640 => price=9600.9 1580804880 => price=9579.4 1580805120 => price=9624.2 1580805360 => price=9740.5 1580805600 => price=9642.1 1580805840 => price=9500.1 1580806080 => price=9450.2 1580806320 => price=9400.3 1580806560 => price=9350.4 1580806800 => price=9300.5

1580807040 => price=9250.6 1580807280 => price=9150.8 1580807520 => price=9100.9 1580807760 => price=9240.5 1580808000 => price=9564.7 1580808240 => price=9532.7 1580808480 => price=9421.7 1580808720 => price=9325.7 1580808960 => price=9514.7 1580809200 => price=9647.7 1580809440 => price=9874.7 1580809680 => price=9742.7 1580809920 => price=9532.7 1580810160 => price=9412.7 1580810400 => price=9117.7 (02/04/2020 @ 10:00am)

And all the functions (rollupFirst, rollupLast, rollupMax, rollupMin) operate on these intervals.

Is my vision of the rollup_candlestick() result is wrong? How should I use the rollup_candlestick() function to get OHLC values on the specified interval (from start to end values)?

test_requests.txt

VictoriaMetrics/VictoriaMetrics

Answer questions valyala

The bugfix is available starting from v1.33.1. Closing the issue as fixed.

useful!

Related questions

Remote write for Prometheus not working hot 1
Graph missing some points hot 1
How to write data to VictoriaMetrics individually in batches? hot 1
Add data deduplication from HA Prometheus pair based on `--query.replica-label` arg similar to Thanos Query hot 1
Can't start VictoriaMetrics use docker-compose and volume mapping on Windows hot 1
While under heavy load getting error panic hot 1
While under heavy load getting error panic hot 1
Failure to deploy with `helm template` in ArgoCD hot 1
While under heavy load getting error panic hot 1
Windows build hot 1
Increase default value for -search.maxPointsPerTimeseries hot 1
changing precisionBits doesn't result in change in precision of stored value hot 1
Drop-in replacement prometheus not work with promxy (Prometheus HA) hot 1
Github User Rank List