Use specified time range, default to class value (#80557)

This commit is contained in:
Javier Ruiz
2024-01-19 13:44:56 +01:00
committed by GitHub
parent 8c77dd8bb8
commit ea37cee435
2 changed files with 13 additions and 6 deletions

View File

@@ -706,10 +706,12 @@ export class PrometheusDatasource
const expr = promQueryModeller.renderLabels(labelFilters);
if (this.hasLabelsMatchAPISupport()) {
return (await this.languageProvider.fetchSeriesValuesWithMatch(options.key, expr)).map((v) => ({
value: v,
text: v,
}));
return (await this.languageProvider.fetchSeriesValuesWithMatch(options.key, expr, options.timeRange)).map(
(v) => ({
value: v,
text: v,
})
);
}
const params = this.getTimeRangeParams(options.timeRange ?? getDefaultTimeRange());

View File

@@ -239,11 +239,16 @@ export default class PromQlLanguageProvider extends LanguageProvider {
* Fetches all values for a label, with optional match[]
* @param name
* @param match
* @param timeRange
*/
fetchSeriesValuesWithMatch = async (name: string, match?: string): Promise<string[]> => {
fetchSeriesValuesWithMatch = async (
name: string,
match?: string,
timeRange: TimeRange = this.timeRange
): Promise<string[]> => {
const interpolatedName = name ? this.datasource.interpolateString(name) : null;
const interpolatedMatch = match ? this.datasource.interpolateString(match) : null;
const range = this.datasource.getAdjustedInterval(this.timeRange);
const range = this.datasource.getAdjustedInterval(timeRange);
const urlParams = {
...range,
...(interpolatedMatch && { 'match[]': interpolatedMatch }),