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

pull/80601/head
Javier Ruiz 1 year ago committed by GitHub
parent 8c77dd8bb8
commit ea37cee435
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 10
      public/app/plugins/datasource/prometheus/datasource.ts
  2. 9
      public/app/plugins/datasource/prometheus/language_provider.ts

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

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

Loading…
Cancel
Save