diff --git a/public/app/plugins/datasource/loki/querybuilder/components/LokiQueryBuilder.test.tsx b/public/app/plugins/datasource/loki/querybuilder/components/LokiQueryBuilder.test.tsx
index bacd008c6f4..64347e14028 100644
--- a/public/app/plugins/datasource/loki/querybuilder/components/LokiQueryBuilder.test.tsx
+++ b/public/app/plugins/datasource/loki/querybuilder/components/LokiQueryBuilder.test.tsx
@@ -57,6 +57,26 @@ describe('LokiQueryBuilder', () => {
await waitFor(() => expect(screen.getByText('job')).toBeInTheDocument());
});
+ it('does refetch label values with the correct timerange', async () => {
+ const props = createDefaultProps();
+ props.datasource.getDataSamples = jest.fn().mockResolvedValue([]);
+ props.datasource.languageProvider.fetchSeriesLabels = jest
+ .fn()
+ .mockReturnValue({ job: ['a'], instance: ['b'], baz: ['bar'] });
+
+ render();
+ await userEvent.click(screen.getByLabelText('Add'));
+ const labels = screen.getByText(/Label filters/);
+ const selects = getAllByRole(getSelectParent(labels)!, 'combobox');
+ await userEvent.click(selects[3]);
+ await waitFor(() => expect(screen.getByText('job')).toBeInTheDocument());
+ await userEvent.click(screen.getByText('job'));
+ await userEvent.click(selects[5]);
+ expect(props.datasource.languageProvider.fetchSeriesLabels).toHaveBeenNthCalledWith(2, '{baz="bar"}', {
+ timeRange: mockTimeRange,
+ });
+ });
+
it('does not show already existing label names as option in label filter', async () => {
const props = createDefaultProps();
props.datasource.getDataSamples = jest.fn().mockResolvedValue([]);
diff --git a/public/app/plugins/datasource/loki/querybuilder/components/LokiQueryBuilder.tsx b/public/app/plugins/datasource/loki/querybuilder/components/LokiQueryBuilder.tsx
index 6cea7c08267..ad0e6c4c814 100644
--- a/public/app/plugins/datasource/loki/querybuilder/components/LokiQueryBuilder.tsx
+++ b/public/app/plugins/datasource/loki/querybuilder/components/LokiQueryBuilder.tsx
@@ -78,7 +78,7 @@ export const LokiQueryBuilder = React.memo(
values = await datasource.languageProvider.fetchLabelValues(forLabel.label, { timeRange });
} else {
const expr = lokiQueryModeller.renderLabels(labelsToConsider);
- const result = await datasource.languageProvider.fetchSeriesLabels(expr);
+ const result = await datasource.languageProvider.fetchSeriesLabels(expr, { timeRange });
values = result[datasource.interpolateString(forLabel.label)];
}