Skip to content

Commit e589257

Browse files
author
Kishore Kumaar Natarajan
committed
MDS Live Queries Support
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
1 parent 8f94a7b commit e589257

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

server/routes/index.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -434,16 +434,22 @@ export function defineRoutes(router: IRouter, dataSourceEnabled: boolean) {
434434
wlmGroupId?: string;
435435
};
436436

437-
const client =
438-
!dataSourceEnabled || !dataSourceId
439-
? context.queryInsights_plugin.queryInsightsClient.asScoped(request).callAsCurrentUser
440-
: context.dataSource.opensearch.legacy.getClient(dataSourceId);
441-
442437
// Call the appropriate API based on whether wlm_group is provided
443438
const hasGroup = typeof wlmGroup === 'string' && wlmGroup.trim().length > 0;
444-
const res = hasGroup
445-
? await client('queryInsights.getLiveQueriesWLMGroup', { wlmGroupId: wlmGroup })
446-
: await client('queryInsights.getLiveQueries');
439+
let res;
440+
441+
if (!dataSourceEnabled || !dataSourceId) {
442+
const client = context.queryInsights_plugin.queryInsightsClient.asScoped(request)
443+
.callAsCurrentUser;
444+
res = hasGroup
445+
? await client('queryInsights.getLiveQueriesWLMGroup', { wlmGroupId: wlmGroup })
446+
: await client('queryInsights.getLiveQueries');
447+
} else {
448+
const client = context.dataSource.opensearch.legacy.getClient(dataSourceId);
449+
res = hasGroup
450+
? await client.callAPI('queryInsights.getLiveQueriesWLMGroup', { wlmGroupId: wlmGroup })
451+
: await client.callAPI('queryInsights.getLiveQueries', {});
452+
}
447453

448454
if (!res || res.ok === false) {
449455
throw new Error(res?.error || 'Query Insights service returned an error');

0 commit comments

Comments
 (0)