[v11.1.x] Prometheus: Don't use match[] parameter if there is no metric (#89385)
Prometheus: Don't use match[] parameter if there is no metric (#89352)
don't use match[] parameter if there is no metric
(cherry picked from commit 76047d9365)
Co-authored-by: ismail simsek <ismailsimsek09@gmail.com>
This commit is contained in:
co-authored by
ismail simsek
parent
e62f0388da
commit
3531b585e3
@@ -505,6 +505,20 @@ describe('Language completion provider', () => {
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
it('should dont send match[] parameter if there is no metric', async () => {
|
||||
const mockQueries: PromQuery[] = [
|
||||
{
|
||||
refId: 'A',
|
||||
expr: '',
|
||||
},
|
||||
];
|
||||
const fetchLabel = languageProvider.fetchLabels;
|
||||
const requestSpy = jest.spyOn(languageProvider, 'request');
|
||||
await fetchLabel(tr, mockQueries);
|
||||
expect(requestSpy).toHaveBeenCalled();
|
||||
expect(requestSpy.mock.calls[0][0].indexOf('match[]')).toEqual(-1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -219,11 +219,13 @@ export default class PromQlLanguageProvider extends LanguageProvider {
|
||||
const searchParams = new URLSearchParams({ ...timeParams });
|
||||
queries?.forEach((q) => {
|
||||
const visualQuery = buildVisualQueryFromString(q.expr);
|
||||
searchParams.append('match[]', visualQuery.query.metric);
|
||||
if (visualQuery.query.binaryQueries) {
|
||||
visualQuery.query.binaryQueries.forEach((bq) => {
|
||||
searchParams.append('match[]', bq.query.metric);
|
||||
});
|
||||
if (visualQuery.query.metric !== '') {
|
||||
searchParams.append('match[]', visualQuery.query.metric);
|
||||
if (visualQuery.query.binaryQueries) {
|
||||
visualQuery.query.binaryQueries.forEach((bq) => {
|
||||
searchParams.append('match[]', bq.query.metric);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user