From 40cdfeb00b4e15ee3d65e70d9a99b7d603daf597 Mon Sep 17 00:00:00 2001 From: Sven Grossmann Date: Thu, 22 Aug 2024 09:12:50 +0200 Subject: [PATCH] Loki: Add `logsample` supporting query type (#92082) * Loki: Add `logsample` supporting query type * use `SupportingQueryType` * add missing test --- public/app/plugins/datasource/loki/datasource.test.ts | 3 +++ public/app/plugins/datasource/loki/datasource.ts | 1 + 2 files changed, 4 insertions(+) diff --git a/public/app/plugins/datasource/loki/datasource.test.ts b/public/app/plugins/datasource/loki/datasource.test.ts index 7fb44ddaf39..dfe34851ad9 100644 --- a/public/app/plugins/datasource/loki/datasource.test.ts +++ b/public/app/plugins/datasource/loki/datasource.test.ts @@ -1529,6 +1529,7 @@ describe('LokiDatasource', () => { queryType: 'range', refId: 'log-sample-A', maxLines: 20, + supportingQueryType: SupportingQueryType.LogsSample, }); }); @@ -1547,6 +1548,7 @@ describe('LokiDatasource', () => { queryType: LokiQueryType.Range, refId: 'log-sample-A', maxLines: 20, + supportingQueryType: SupportingQueryType.LogsSample, }); }); @@ -1564,6 +1566,7 @@ describe('LokiDatasource', () => { expr: '{label="value"}', queryType: LokiQueryType.Range, refId: 'log-sample-A', + supportingQueryType: SupportingQueryType.LogsSample, maxLines: 5, }); }); diff --git a/public/app/plugins/datasource/loki/datasource.ts b/public/app/plugins/datasource/loki/datasource.ts index 80a95dda5a5..de497360aa1 100644 --- a/public/app/plugins/datasource/loki/datasource.ts +++ b/public/app/plugins/datasource/loki/datasource.ts @@ -242,6 +242,7 @@ export class LokiDatasource refId: `${REF_ID_STARTER_LOG_SAMPLE}${normalizedQuery.refId}`, expr: getLogQueryFromMetricsQuery(expr), maxLines: Number.isNaN(Number(options.limit)) ? this.maxLines : Number(options.limit), + supportingQueryType: SupportingQueryType.LogsSample, }; default: