Prometheus: Fix interpolating minStep for range queries when incremental querying enabled (#107715)
* return calculatedMinStep in first frame of the response * update test files * make the custom metadata as type of map[string]any * append calculatedMinStep to custom metadata * fix exemplar frame checking
This commit is contained in:
@@ -646,7 +646,7 @@ describe('QueryCache: Prometheus', function () {
|
||||
});
|
||||
|
||||
describe('findDataPointStep', () => {
|
||||
it('should interpolate custom interval', () => {
|
||||
it('should interpolate custom interval when there is no calculatedMinStep in response', () => {
|
||||
const mockApplyInterpolation = jest.fn().mockImplementation(() => '1m');
|
||||
const req = mockPromRequest();
|
||||
req.targets[0].interval = '$interval';
|
||||
@@ -654,4 +654,20 @@ describe('findDataPointStep', () => {
|
||||
findDatapointStep(req, respFrames, mockApplyInterpolation);
|
||||
expect(mockApplyInterpolation).toBeCalledTimes(1);
|
||||
});
|
||||
|
||||
it('should use the calculated minStep coming in response frame', () => {
|
||||
const mockApplyInterpolation = jest.fn().mockImplementation(() => '1m');
|
||||
const req = mockPromRequest();
|
||||
// Cannot be interpolated on frontend as it was calculated on backend.
|
||||
req.targets[0].interval = '$__rate_interval';
|
||||
const respFrames = trimmedFirstPointInPromFrames as unknown as DataFrame[];
|
||||
const expectedMinStep = 60000;
|
||||
respFrames[0].meta = {
|
||||
custom: {
|
||||
calculatedMinStep: expectedMinStep,
|
||||
},
|
||||
};
|
||||
const result = findDatapointStep(req, respFrames, mockApplyInterpolation);
|
||||
expect(result).toBe(expectedMinStep);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -282,7 +282,9 @@ export function findDatapointStep(
|
||||
|
||||
let dataPointStep = request.intervalMs;
|
||||
if (target?.interval) {
|
||||
const minStepMs = rangeUtil.intervalToMs(applyInterpolation(target.interval));
|
||||
const minStepMs =
|
||||
respFrames[0].meta?.custom?.['calculatedMinStep'] ??
|
||||
rangeUtil.intervalToMs(applyInterpolation(target.interval, request.scopedVars));
|
||||
if (minStepMs > request.intervalMs) {
|
||||
dataPointStep = minStepMs;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user