mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Loki: don't send empty vector selector to /labels API (#98547)
* fix: don't send empty vector selector to /labels API
This commit is contained in:
parent
09c4543d11
commit
3ba0cd23c2
@ -461,6 +461,15 @@ describe('Language completion provider', () => {
|
||||
config.featureToggles.lokiLabelNamesQueryApi = lokiLabelNamesQueryApi;
|
||||
});
|
||||
|
||||
it('should exclude empty vector selector', async () => {
|
||||
const datasourceWithLabels = setup({ foo: [], bar: [], __name__: [], __stream_shard__: [] });
|
||||
|
||||
const instance = new LanguageProvider(datasourceWithLabels);
|
||||
instance.request = jest.fn();
|
||||
await instance.fetchLabels({ streamSelector: '{}' });
|
||||
expect(instance.request).toBeCalledWith('labels', { end: 1560163909000, start: 1560153109000 });
|
||||
});
|
||||
|
||||
it('should use series endpoint for request with stream selector', async () => {
|
||||
const datasourceWithLabels = setup({});
|
||||
datasourceWithLabels.languageProvider.request = jest.fn();
|
||||
|
@ -174,7 +174,7 @@ export default class LokiLanguageProvider extends LanguageProvider {
|
||||
const range = options?.timeRange ?? this.getDefaultTimeRange();
|
||||
const { start, end } = this.datasource.getTimeRangeParams(range);
|
||||
const params: Record<string, string | number> = { start, end };
|
||||
if (options?.streamSelector) {
|
||||
if (options?.streamSelector && options?.streamSelector !== EMPTY_SELECTOR) {
|
||||
params['query'] = options.streamSelector;
|
||||
}
|
||||
const res = await this.request(url, params);
|
||||
|
Loading…
Reference in New Issue
Block a user