diff --git a/public/app/plugins/datasource/cloudwatch/query-runner/CloudWatchLogsQueryRunner.test.ts b/public/app/plugins/datasource/cloudwatch/query-runner/CloudWatchLogsQueryRunner.test.ts index d6a40c4b89c..b38fd288633 100644 --- a/public/app/plugins/datasource/cloudwatch/query-runner/CloudWatchLogsQueryRunner.test.ts +++ b/public/app/plugins/datasource/cloudwatch/query-runner/CloudWatchLogsQueryRunner.test.ts @@ -76,6 +76,17 @@ describe('CloudWatchLogsQueryRunner', () => { }); }); + it('does not append -logs to the requestId if requestId is not provided', async () => { + const { runner, queryMock } = setupMockedLogsQueryRunner(); + + const request = { + ...LogsRequestMock, + }; + await expect(runner.handleLogQueries(LogsRequestMock.targets, request, queryMock)).toEmitValuesWith(() => { + expect(queryMock.mock.calls[0][0].requestId).toEqual(''); + }); + }); + it('should request to start each query and then request to get the query results', async () => { const { runner } = setupMockedLogsQueryRunner(); diff --git a/public/app/plugins/datasource/cloudwatch/query-runner/CloudWatchLogsQueryRunner.ts b/public/app/plugins/datasource/cloudwatch/query-runner/CloudWatchLogsQueryRunner.ts index 97ba156b287..0ccc22029c1 100644 --- a/public/app/plugins/datasource/cloudwatch/query-runner/CloudWatchLogsQueryRunner.ts +++ b/public/app/plugins/datasource/cloudwatch/query-runner/CloudWatchLogsQueryRunner.ts @@ -415,12 +415,14 @@ export class CloudWatchLogsQueryRunner extends CloudWatchRequest { options?: DataQueryRequest ): Observable { const range = options?.range || getDefaultTimeRange(); + // append -logs to prevent requestId from matching metric queries from the same panel + const requestId = options?.requestId ? `${options?.requestId}-logs` : ''; const requestParams: DataQueryRequest = { ...options, range, skipQueryCache: true, - requestId: options?.requestId + '-logs' || '', // adding -logs to prevent requestId from matching metric queries from the same panel + requestId, interval: options?.interval || '', // dummy intervalMs: options?.intervalMs || 1, // dummy scopedVars: options?.scopedVars || {}, // dummy