Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Monitoring] Fix UI error when alerting is not available #77179

Merged
merged 4 commits into from
Sep 11, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -119,67 +119,75 @@ export async function getClustersFromRequest(
// add alerts data
if (isInCodePath(codePaths, [CODE_PATH_ALERTS])) {
const alertsClient = req.getAlertsClient();
if (alertsClient) {
for (const cluster of clusters) {
const verification = verifyMonitoringLicense(req.server);
if (!verification.enabled) {
// return metadata detailing that alerts is disabled because of the monitoring cluster license
cluster.alerts = {
alertsMeta: {
enabled: verification.enabled,
message: verification.message, // NOTE: this is only defined when the alert feature is disabled
},
list: {},
};
continue;
}

// check the license type of the production cluster for alerts feature support
const license = cluster.license || {};
const prodLicenseInfo = checkLicenseForAlerts(
license.type,
license.status === 'active',
'production'
);
if (prodLicenseInfo.clusterAlerts.enabled) {
cluster.alerts = {
list: await fetchStatus(
alertsClient,
req.server.plugins.monitoring.info,
undefined,
cluster.cluster_uuid,
start,
end,
[]
),
alertsMeta: {
enabled: true,
},
};
continue;
}
for (const cluster of clusters) {
const verification = verifyMonitoringLicense(req.server);
if (!verification.enabled) {
// return metadata detailing that alerts is disabled because of the monitoring cluster license
cluster.alerts = {
alertsMeta: {
enabled: verification.enabled,
message: verification.message, // NOTE: this is only defined when the alert feature is disabled
},
list: {},
};
continue;
}

if (!alertsClient) {
cluster.alerts = {
list: {},
alertsMeta: {
enabled: true,
},
clusterMeta: {
};
continue;
}

// check the license type of the production cluster for alerts feature support
const license = cluster.license || {};
const prodLicenseInfo = checkLicenseForAlerts(
license.type,
license.status === 'active',
'production'
);
if (prodLicenseInfo.clusterAlerts.enabled) {
cluster.alerts = {
list: await fetchStatus(
alertsClient,
req.server.plugins.monitoring.info,
undefined,
cluster.cluster_uuid,
start,
end,
[]
),
alertsMeta: {
enabled: false,
message: i18n.translate(
'xpack.monitoring.clusterAlerts.unsupportedClusterAlertsDescription',
{
defaultMessage:
'Cluster [{clusterName}] license type [{licenseType}] does not support Cluster Alerts',
values: {
clusterName: cluster.cluster_name,
licenseType: `${license.type}`,
},
}
),
},
};
continue;
}

cluster.alerts = {
list: {},
alertsMeta: {
enabled: true,
},
clusterMeta: {
enabled: false,
message: i18n.translate(
'xpack.monitoring.clusterAlerts.unsupportedClusterAlertsDescription',
{
defaultMessage:
'Cluster [{clusterName}] license type [{licenseType}] does not support Cluster Alerts',
values: {
clusterName: cluster.cluster_name,
licenseType: `${license.type}`,
},
}
),
},
};
}
}
}
Expand Down