From d51e63520cad6779728cf53bfaaf89048cfea9a7 Mon Sep 17 00:00:00 2001 From: Sven Grossmann Date: Wed, 26 Apr 2023 13:26:07 +0200 Subject: [PATCH] Loki: Fix log samples using `instant` queries (#67271) change log samples queryType to always be `range` --- public/app/plugins/datasource/loki/datasource.test.ts | 7 +++---- public/app/plugins/datasource/loki/datasource.ts | 3 ++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/public/app/plugins/datasource/loki/datasource.test.ts b/public/app/plugins/datasource/loki/datasource.test.ts index 2f789da2dd0..ff23e68c88c 100644 --- a/public/app/plugins/datasource/loki/datasource.test.ts +++ b/public/app/plugins/datasource/loki/datasource.test.ts @@ -932,8 +932,7 @@ describe('LokiDatasource', () => { ) ).toEqual({ expr: 'sum by (level) (count_over_time({label=value}[$__interval]))', - instant: false, - queryType: 'range', + queryType: LokiQueryType.Range, refId: 'log-volume-A', supportingQueryType: SupportingQueryType.LogsVolume, }); @@ -997,7 +996,7 @@ describe('LokiDatasource', () => { ) ).toEqual({ expr: '{label=value}', - queryType: 'instant', + queryType: LokiQueryType.Range, refId: 'log-sample-A', maxLines: 20, }); @@ -1015,7 +1014,7 @@ describe('LokiDatasource', () => { ) ).toEqual({ expr: '{label=value}', - queryType: 'instant', + queryType: LokiQueryType.Range, refId: 'log-sample-A', maxLines: 5, }); diff --git a/public/app/plugins/datasource/loki/datasource.ts b/public/app/plugins/datasource/loki/datasource.ts index 674c382489e..e63e7ed127f 100644 --- a/public/app/plugins/datasource/loki/datasource.ts +++ b/public/app/plugins/datasource/loki/datasource.ts @@ -193,7 +193,7 @@ export class LokiDatasource return { ...normalizedQuery, refId: `${REF_ID_STARTER_LOG_VOLUME}${normalizedQuery.refId}`, - instant: false, + queryType: LokiQueryType.Range, supportingQueryType: SupportingQueryType.LogsVolume, expr: `sum by (level) (count_over_time(${expr}[$__interval]))`, }; @@ -206,6 +206,7 @@ export class LokiDatasource } return { ...normalizedQuery, + queryType: LokiQueryType.Range, refId: `${REF_ID_STARTER_LOG_SAMPLE}${normalizedQuery.refId}`, expr: getLogQueryFromMetricsQuery(expr), maxLines: Number.isNaN(Number(options.limit)) ? this.maxLines : Number(options.limit),