From da3aa0a7f9865ecc38b8df1c320d883420b45864 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 20 Oct 2025 20:49:32 +0000 Subject: [PATCH] MDS Live Queries Support (#403) Signed-off-by: Kishore Kumaar Natarajan Co-authored-by: Kishore Kumaar Natarajan Co-authored-by: Chenyang Ji (cherry picked from commit 95db4186fe218f13a16846946a9ee2675e994826) Signed-off-by: github-actions[bot] --- server/routes/index.ts | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/server/routes/index.ts b/server/routes/index.ts index a6878c3b..2daba2d5 100644 --- a/server/routes/index.ts +++ b/server/routes/index.ts @@ -434,16 +434,22 @@ export function defineRoutes(router: IRouter, dataSourceEnabled: boolean) { wlmGroupId?: string; }; - const client = - !dataSourceEnabled || !dataSourceId - ? context.queryInsights_plugin.queryInsightsClient.asScoped(request).callAsCurrentUser - : context.dataSource.opensearch.legacy.getClient(dataSourceId); - // Call the appropriate API based on whether wlm_group is provided const hasGroup = typeof wlmGroup === 'string' && wlmGroup.trim().length > 0; - const res = hasGroup - ? await client('queryInsights.getLiveQueriesWLMGroup', { wlmGroupId: wlmGroup }) - : await client('queryInsights.getLiveQueries'); + let res; + + if (!dataSourceEnabled || !dataSourceId) { + const client = context.queryInsights_plugin.queryInsightsClient.asScoped(request) + .callAsCurrentUser; + res = hasGroup + ? await client('queryInsights.getLiveQueriesWLMGroup', { wlmGroupId: wlmGroup }) + : await client('queryInsights.getLiveQueries'); + } else { + const client = context.dataSource.opensearch.legacy.getClient(dataSourceId); + res = hasGroup + ? await client.callAPI('queryInsights.getLiveQueriesWLMGroup', { wlmGroupId: wlmGroup }) + : await client.callAPI('queryInsights.getLiveQueries', {}); + } if (!res || res.ok === false) { throw new Error(res?.error || 'Query Insights service returned an error');