mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Fixing issue 16090 where Grafana uses illegal characters in requests … (#21447)
* Fixing issue 16090 where Grafana uses illegal characters in requests to Prometheus * Rebase with Grafana and Merge branch 'master' of https://github.com/BhartiAgrawalNvidia/grafana into fix-16090 # Conflicts: # public/app/plugins/datasource/prometheus/language_provider.ts * Rebase with Grafana and Merge branch 'master' of https://github.com/BhartiAgrawalNvidia/grafana into fix-16090 # Conflicts: # public/app/plugins/datasource/prometheus/language_provider.ts * Use querystring to escape the url Co-authored-by: Andrej Ocenas <mr.ocenas@gmail.com> Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
committed by
GitHub
parent
98420c63d1
commit
ce8df91cc9
@@ -403,14 +403,20 @@ export default class PromQlLanguageProvider extends LanguageProvider {
|
||||
*/
|
||||
fetchSeriesLabels = async (name: string, withName?: boolean): Promise<Record<string, string[]>> => {
|
||||
const tRange = this.datasource.getTimeRange();
|
||||
const url = `/api/v1/series?match[]=${name}&start=${tRange['start']}&end=${tRange['end']}`;
|
||||
const params = new URLSearchParams({
|
||||
'match[]': name,
|
||||
start: tRange['start'].toString(),
|
||||
end: tRange['end'].toString(),
|
||||
});
|
||||
const url = `/api/v1/series?${params.toString()}`;
|
||||
// Cache key is a bit different here. We add the `withName` param and also round up to a minute the intervals.
|
||||
// The rounding may seem strange but makes relative intervals like now-1h less prone to need separate request every
|
||||
// millisecond while still actually getting all the keys for the correct interval. This still can create problems
|
||||
// when user does not the newest values for a minute if already cached.
|
||||
const cacheKey = `/api/v1/series?match[]=${name}&start=${this.roundToMinutes(
|
||||
tRange['start']
|
||||
)}&end=${this.roundToMinutes(tRange['end'])}&withName=${!!withName}`;
|
||||
params.set('start', this.roundToMinutes(tRange['start']).toString());
|
||||
params.set('end', this.roundToMinutes(tRange['end']).toString());
|
||||
params.append('withName', withName ? 'true' : 'false');
|
||||
const cacheKey = `/api/v1/series?${params.toString()}`;
|
||||
let value = this.labelsCache.get(cacheKey);
|
||||
if (!value) {
|
||||
const data = await this.request(url, []);
|
||||
|
||||
Reference in New Issue
Block a user