@@ -119,67 +119,75 @@ export async function getClustersFromRequest(
119119 // add alerts data
120120 if ( isInCodePath ( codePaths , [ CODE_PATH_ALERTS ] ) ) {
121121 const alertsClient = req . getAlertsClient ( ) ;
122- if ( alertsClient ) {
123- for ( const cluster of clusters ) {
124- const verification = verifyMonitoringLicense ( req . server ) ;
125- if ( ! verification . enabled ) {
126- // return metadata detailing that alerts is disabled because of the monitoring cluster license
127- cluster . alerts = {
128- alertsMeta : {
129- enabled : verification . enabled ,
130- message : verification . message , // NOTE: this is only defined when the alert feature is disabled
131- } ,
132- list : { } ,
133- } ;
134- continue ;
135- }
136-
137- // check the license type of the production cluster for alerts feature support
138- const license = cluster . license || { } ;
139- const prodLicenseInfo = checkLicenseForAlerts (
140- license . type ,
141- license . status === 'active' ,
142- 'production'
143- ) ;
144- if ( prodLicenseInfo . clusterAlerts . enabled ) {
145- cluster . alerts = {
146- list : await fetchStatus (
147- alertsClient ,
148- req . server . plugins . monitoring . info ,
149- undefined ,
150- cluster . cluster_uuid ,
151- start ,
152- end ,
153- [ ]
154- ) ,
155- alertsMeta : {
156- enabled : true ,
157- } ,
158- } ;
159- continue ;
160- }
122+ for ( const cluster of clusters ) {
123+ const verification = verifyMonitoringLicense ( req . server ) ;
124+ if ( ! verification . enabled ) {
125+ // return metadata detailing that alerts is disabled because of the monitoring cluster license
126+ cluster . alerts = {
127+ alertsMeta : {
128+ enabled : verification . enabled ,
129+ message : verification . message , // NOTE: this is only defined when the alert feature is disabled
130+ } ,
131+ list : { } ,
132+ } ;
133+ continue ;
134+ }
161135
136+ if ( ! alertsClient ) {
162137 cluster . alerts = {
163138 list : { } ,
164139 alertsMeta : {
165- enabled : true ,
166- } ,
167- clusterMeta : {
168140 enabled : false ,
169- message : i18n . translate (
170- 'xpack.monitoring.clusterAlerts.unsupportedClusterAlertsDescription' ,
171- {
172- defaultMessage :
173- 'Cluster [{clusterName}] license type [{licenseType}] does not support Cluster Alerts' ,
174- values : {
175- clusterName : cluster . cluster_name ,
176- licenseType : `${ license . type } ` ,
177- } ,
178- }
179- ) ,
180141 } ,
181142 } ;
143+ continue ;
144+ }
145+
146+ // check the license type of the production cluster for alerts feature support
147+ const license = cluster . license || { } ;
148+ const prodLicenseInfo = checkLicenseForAlerts (
149+ license . type ,
150+ license . status === 'active' ,
151+ 'production'
152+ ) ;
153+ if ( prodLicenseInfo . clusterAlerts . enabled ) {
154+ cluster . alerts = {
155+ list : await fetchStatus (
156+ alertsClient ,
157+ req . server . plugins . monitoring . info ,
158+ undefined ,
159+ cluster . cluster_uuid ,
160+ start ,
161+ end ,
162+ [ ]
163+ ) ,
164+ alertsMeta : {
165+ enabled : true ,
166+ } ,
167+ } ;
168+ continue ;
182169 }
170+
171+ cluster . alerts = {
172+ list : { } ,
173+ alertsMeta : {
174+ enabled : false ,
175+ } ,
176+ clusterMeta : {
177+ enabled : false ,
178+ message : i18n . translate (
179+ 'xpack.monitoring.clusterAlerts.unsupportedClusterAlertsDescription' ,
180+ {
181+ defaultMessage :
182+ 'Cluster [{clusterName}] license type [{licenseType}] does not support Cluster Alerts' ,
183+ values : {
184+ clusterName : cluster . cluster_name ,
185+ licenseType : `${ license . type } ` ,
186+ } ,
187+ }
188+ ) ,
189+ } ,
190+ } ;
183191 }
184192 }
185193 }
0 commit comments