@@ -126,12 +126,13 @@ export const InflightQueries = ({
126126
127127 try {
128128 const httpQuery = dataSource ?. id ? { dataSourceId : dataSource . id } : undefined ;
129- const res = await core . http . get ( '/api/cat_plugins' , { query : httpQuery } ) ;
130- const has = ! ! res ?. hasWlm ;
131- wlmCacheRef . current [ cacheKey ] = has ;
132- return has ;
129+ const res = await core . http . get ( '/api/_wlm/workload_group' , { query : httpQuery } ) ;
130+ const hasValidStructure =
131+ res && typeof res === 'object' && Array . isArray ( res . workload_groups ) ;
132+ wlmCacheRef . current [ cacheKey ] = hasValidStructure ;
133+ return hasValidStructure ;
133134 } catch ( e ) {
134- console . warn ( '[LiveQueries] _cat/plugins detection failed; assuming WLM unavailable' , e ) ;
135+ console . warn ( '[LiveQueries] WLM workload group API failed; assuming WLM unavailable' , e ) ;
135136 wlmCacheRef . current [ cacheKey ] = false ;
136137 return false ;
137138 }
@@ -141,11 +142,14 @@ export const InflightQueries = ({
141142 const checkWlmSupport = async ( ) => {
142143 try {
143144 const version = await getVersionOnce ( dataSource ?. id || '' ) ;
145+ console . log ( '[DEBUG] OpenSearch version detected:' , version ) ;
144146 const versionSupported = isVersion33OrHigher ( version ) ;
147+ console . log ( '[DEBUG] Version 3.3+ supported:' , versionSupported ) ;
145148 setWlmGroupsSupported ( versionSupported ) ;
146149
147150 if ( versionSupported ) {
148151 const hasWlm = await detectWlm ( ) ;
152+ console . log ( '[DEBUG] WLM available:' , hasWlm ) ;
149153 setWlmAvailable ( hasWlm ) ;
150154 } else {
151155 setWlmAvailable ( false ) ;
@@ -167,17 +171,15 @@ export const InflightQueries = ({
167171 } > ( { total_completions : 0 , total_cancellations : 0 , total_rejections : 0 } ) ;
168172
169173 const fetchActiveWlmGroups = useCallback ( async ( ) => {
170- if ( ! wlmGroupsSupported ) {
171- setWorkloadGroupStats ( { total_completions : 0 , total_cancellations : 0 , total_rejections : 0 } ) ;
172- setWlmGroupOptions ( [ ] ) ;
173- return { } ;
174- }
174+ console . log ( '[DEBUG] fetchActiveWlmGroups called, wlmGroupsSupported:' , wlmGroupsSupported ) ;
175175
176176 const httpQuery = dataSource ?. id ? { dataSourceId : dataSource . id } : undefined ;
177177 let statsBody : WlmStatsBody = { } ;
178178 try {
179+ console . log ( '[DEBUG] Making WLM stats API call to:' , API_ENDPOINTS . WLM_STATS ) ;
179180 const statsRes = await core . http . get ( API_ENDPOINTS . WLM_STATS , { query : httpQuery } ) ;
180- statsBody = ( statsRes as { body ?: unknown } ) . body as WlmStatsBody ;
181+ console . log ( '[DEBUG] WLM stats response:' , statsRes ) ;
182+ statsBody = statsRes as WlmStatsBody ;
181183 } catch ( e ) {
182184 console . warn ( '[LiveQueries] Failed to fetch WLM stats' , e ) ;
183185 setWorkloadGroupStats ( { total_completions : 0 , total_cancellations : 0 , total_rejections : 0 } ) ;
@@ -229,16 +231,25 @@ export const InflightQueries = ({
229231 }
230232 }
231233
234+ console . log (
235+ '[DEBUG] Parsed stats - completions:' ,
236+ completions ,
237+ 'cancellations:' ,
238+ cancellations ,
239+ 'rejections:' ,
240+ rejections
241+ ) ;
242+
232243 setWorkloadGroupStats ( {
233244 total_completions : completions ,
234245 total_cancellations : cancellations ,
235246 total_rejections : rejections ,
236247 } ) ;
237248
238- // fetch group NAMES only if plugin exists (but do not block the stats)
249+ // fetch group NAMES only if plugin exists and version supported
239250 const idToNameMap : Record < string , string > = { } ;
240251 try {
241- if ( wlmAvailable ) {
252+ if ( wlmAvailable && wlmGroupsSupported ) {
242253 const groupsRes = await core . http . get ( API_ENDPOINTS . WLM_WORKLOAD_GROUP , {
243254 query : httpQuery ,
244255 } ) ;
@@ -253,10 +264,12 @@ export const InflightQueries = ({
253264 console . warn ( '[LiveQueries] Failed to fetch workload groups' , e ) ;
254265 }
255266
256- const options = Array . from ( activeGroupIds ) . map ( ( id ) => ( { id, name : idToNameMap [ id ] || id } ) ) ;
267+ const options = wlmGroupsSupported
268+ ? Array . from ( activeGroupIds ) . map ( ( id ) => ( { id, name : idToNameMap [ id ] || id } ) )
269+ : [ ] ;
257270 setWlmGroupOptions ( options ) ;
258271 return idToNameMap ;
259- } , [ core . http , dataSource ?. id , wlmGroupId , wlmAvailable ] ) ;
272+ } , [ core . http , dataSource ?. id , wlmGroupId , wlmGroupsSupported ] ) ;
260273
261274 const liveQueries = query ?. response ?. live_queries ?? [ ] ;
262275
@@ -353,13 +366,22 @@ export const InflightQueries = ({
353366 if ( isFetching . current ) return ;
354367 isFetching . current = true ;
355368 try {
356- const budget = Math . max ( 2000 , refreshInterval - 500 ) ;
357- const map = await withTimeout ( fetchActiveWlmGroups ( ) , budget ) . catch ( ( ) => undefined ) ;
358- await fetchLiveQueries ( map ) ;
369+ if ( wlmGroupsSupported ) {
370+ try {
371+ await withTimeout ( fetchActiveWlmGroups ( ) , refreshInterval - 500 ) ;
372+ } catch ( e ) {
373+ console . warn ( '[LiveQueries] fetchActiveWlmGroups timed out or failed' , e ) ;
374+ }
375+ }
376+ try {
377+ await withTimeout ( fetchLiveQueries ( ) , refreshInterval - 500 ) ;
378+ } catch ( e ) {
379+ console . warn ( '[LiveQueries] fetchLiveQueries timed out or failed' , e ) ;
380+ }
359381 } finally {
360382 isFetching . current = false ;
361383 }
362- } , [ refreshInterval , fetchActiveWlmGroups , fetchLiveQueries ] ) ;
384+ } , [ refreshInterval , fetchActiveWlmGroups , fetchLiveQueries , wlmGroupsSupported ] ) ;
363385
364386 useEffect ( ( ) => {
365387 void fetchLiveQueriesSafe ( ) ;
@@ -370,7 +392,7 @@ export const InflightQueries = ({
370392 } , refreshInterval ) ;
371393
372394 return ( ) => clearInterval ( interval ) ;
373- } , [ autoRefreshEnabled , refreshInterval , fetchLiveQueriesSafe ] ) ;
395+ } , [ autoRefreshEnabled , refreshInterval , fetchLiveQueriesSafe , wlmGroupsSupported ] ) ;
374396
375397 const [ pagination , setPagination ] = useState ( { pageIndex : 0 } ) ;
376398 const [ tableQuery , setTableQuery ] = useState ( '' ) ;
@@ -574,7 +596,7 @@ export const InflightQueries = ({
574596 < EuiButton
575597 iconType = "refresh"
576598 onClick = { async ( ) => {
577- await fetchLiveQueries ( ) ;
599+ await fetchLiveQueriesSafe ( ) ;
578600 } }
579601 data-test-subj = "live-queries-refresh-button"
580602 >
@@ -906,7 +928,7 @@ export const InflightQueries = ({
906928 key = "refresh-button"
907929 iconType = "refresh"
908930 onClick = { async ( ) => {
909- await fetchLiveQueries ( ) ;
931+ await fetchLiveQueriesSafe ( ) ;
910932 } }
911933 >
912934 Refresh
0 commit comments