Describe the bug
I use same query to Prometheus and VictoriaMetrics in Grafana, but have different graphs in Grafana (see screenshots):
To Reproduce
Use one query to Prometheus and VictoriaMetrics
Expected behavior
Graphs must be same
Screenshots
Graph for prometheus:

Graph for victoriaMetric:

Version
victoria-metrics-20190822-120009-tags-v1.26.0-0-g1272e407
Additional context
This issue can be related to the fact that Prometheus and VictoriaMetrics differently calculate increase:
[1m] in your case.increase - see https://github.com/prometheus/prometheus/issues/3746 .IMHO, VictoriaMetrics' calculations are better than Prometheus' in this case, since they never return floating-point values for integer counter increase.
In order to prove the assumption, could you post graphs for the following query on both Prometheus and VictoriaMetrics on the same time range as graphs above?
ssw_log:counter:by_instance_level_source{job="ssw-log", level="E", instance="ss5-ss-prod-3:3903"}
This will allow calculating manually increase values according to the aforementioned algorithms for VictoriaMetrics and PRometheus.
@a-illiushchenia , are there any updates?
Yes, and it is wery interesting:
I took enather interval:
We have increace 1 point and it dispay correct in Prometheus and VictoriaMetrics:
Prometheus:


VictoriaMetrics:


Prometheus:

VictoriaMetrics:

Hi @a-illiushchenia !
Which instance has that 2 increase on Prometheus pic? Could you pls compare sum and increase for that particular instance in both Prom and VM?
We found the prometheus implementations of increase and delta pretty useless for our data, as the extrapolation performed in the functions does not deliver correct results, Usually actual increases in the metric are ignored.
This is why we replaced our queries
sum(idelta(my_metrics{instance=~"$instance"}[$__interval]) by (something)
with:
sum(my_metrics{instance=~"$instance"} - my_metrics{instance=~"$instance"} offset $__interval >= 0) by (something)
This (although requiring double lookups of the series) correct results and does not miss increases of a time series.
@a-illiushchenia , the graphs show that Prometheus returns incorrect +2 increase for the actual +1 increase for the given time series. And the increase lasts for 30 seconds, while it should last for 1 minute according to [1m] time window passed to increase() function. VictoriaMetrics' graphs look correct.
@lammel , great solution! Note that the query can be improved with with templates and remove_resets() function from Extended PromQL in the following ways:
1) Mention my_metric{instance=~"$instance"} only once.
2) Remove possible counter resets.
The resulting query would look like:
with (
q = remove_resets(my_metrics{instance=~"$instance"})
)
sum(q - q offset $__interval) by (something)
@valyala , the extended promql looks very polished. We will look into VM soon with the prometheus remote write setup.
Do the increase/delta functions work correct without extrapolation in victoria metrics (can I assume no increase is missed)?
From your update in prometheus issue 3806# I assume that VM delta function can be safely used, is efficient and correct.
Do the increase/delta functions work correct without extrapolation in victoria metrics (can I assume no increase is missed)?
Yes, both functions in VictoriaMetrics should return the exact increase / delta on the given time window in square brackets. If the time window is missing, then it is equal to step value - i.e. the interval between two adjacent points on the graph.
As for PromQL, it is great, but unfortunately it cannot be used with Promxy yet, since it understands only standard PromQL :( There are plans to fix this in the future - see this issue for details.
@a-illiushchenia , I'm going to close this issue as working as intended. Feel free re-opening it or adding additional details if you feel that VictoriaMetrics has issues with PromQL results.
Most helpful comment
We found the prometheus implementations of increase and delta pretty useless for our data, as the extrapolation performed in the functions does not deliver correct results, Usually actual increases in the metric are ignored.
This is why we replaced our queries
with:
This (although requiring double lookups of the series) correct results and does not miss increases of a time series.