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] Clearer MB migration state on the overview page #41898

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
import React, { Fragment } from 'react';
import { get, capitalize } from 'lodash';
import { formatNumber } from 'plugins/monitoring/lib/format_number';
import { ClusterItemContainer, HealthStatusIndicator, BytesUsage, BytesPercentageUsage } from './helpers';
import {
ClusterItemContainer,
HealthStatusIndicator,
BytesUsage,
BytesPercentageUsage
} from './helpers';
import {
EuiFlexGrid,
EuiFlexItem,
Expand All @@ -21,6 +26,7 @@ import {
EuiBadge,
EuiToolTip,
EuiFlexGroup,
EuiIcon
} from '@elastic/eui';
import { LicenseText } from './license_text';
import { i18n } from '@kbn/i18n';
Expand Down Expand Up @@ -151,59 +157,79 @@ export function ElasticsearchPanel(props) {
<HealthStatusIndicator status={clusterStats.status} />
);

const licenseText = <LicenseText license={props.license} showLicenseExpiration={props.showLicenseExpiration} />;

const setupModeElasticsearchData = get(setupMode.data, 'elasticsearch');
let setupModeNodesData = null;
if (setupMode.enabled && setupModeElasticsearchData) {
const {
totalUniqueInstanceCount,
totalUniqueFullyMigratedCount,
totalUniquePartiallyMigratedCount
} = setupModeElasticsearchData;
const allMonitoredByMetricbeat = totalUniqueInstanceCount > 0 &&
(totalUniqueFullyMigratedCount === totalUniqueInstanceCount || totalUniquePartiallyMigratedCount === totalUniqueInstanceCount);
const internalCollectionOn = totalUniquePartiallyMigratedCount > 0;
if (!allMonitoredByMetricbeat || internalCollectionOn) {
let tooltipText = null;

if (!allMonitoredByMetricbeat) {
tooltipText = i18n.translate('xpack.monitoring.cluster.overview.elasticsearchPanel.setupModeNodesTooltip.oneInternal', {
defaultMessage: `There's at least one node that isn't being monitored using Metricbeat. Click the flag icon to visit the nodes
listing page and find out more information about the status of each node.`
});
}
else if (internalCollectionOn) {
tooltipText = i18n.translate('xpack.monitoring.cluster.overview.elasticsearchPanel.setupModeNodesTooltip.disableInternal', {
defaultMessage: `All nodes are being monitored using Metricbeat but internal collection still needs to be turned off. Click the
flag icon to visit the nodes listing page and disable internal collection.`
});
}

setupModeNodesData = (
<EuiFlexItem grow={false}>
<EuiToolTip
position="top"
content={tooltipText}
>
<EuiLink onClick={goToNodes}>
<EuiIcon type="flag" color="warning"/>
</EuiLink>
</EuiToolTip>
</EuiFlexItem>
);
}
}

const showMlJobs = () => {
// if license doesn't support ML, then `ml === null`
if (props.ml) {
const gotoURL = '#/elasticsearch/ml_jobs';
return (
<>
<EuiDescriptionListTitle>
<EuiLink href={gotoURL}>
<EuiLink
href={gotoURL}
>
<FormattedMessage
id="xpack.monitoring.cluster.overview.esPanel.jobsLabel"
defaultMessage="Jobs"
/>
</EuiLink>
</EuiDescriptionListTitle>
<EuiDescriptionListDescription data-test-subj="esMlJobs">
<EuiLink href={gotoURL}>{props.ml.jobs}</EuiLink>
<EuiLink
href={gotoURL}
>
{props.ml.jobs}
</EuiLink>
</EuiDescriptionListDescription>
</>
);
}
return null;
};

const licenseText = <LicenseText license={props.license} showLicenseExpiration={props.showLicenseExpiration} />;

let setupModeNodesData = null;
if (setupMode.enabled && setupMode.data) {
const elasticsearchData = get(setupMode.data, 'elasticsearch.byUuid');
const migratedNodesCount = Object.values(elasticsearchData).filter(node => node.isFullyMigrated).length;
const totalNodesCount = Object.values(elasticsearchData).length;

const badgeColor = migratedNodesCount === totalNodesCount
? 'secondary'
: 'danger';

setupModeNodesData = (
<EuiFlexItem grow={false}>
<EuiToolTip
position="top"
content={i18n.translate('xpack.monitoring.cluster.overview.esPanel.setupModeNodesTooltip', {
defaultMessage: `These numbers indicate how many detected monitored nodes versus how many
detected total nodes. If there are more detected nodes than monitored nodes, click the Nodes
link and you will be guided in how to setup monitoring for the missing node.`
})}
>
<EuiBadge color={badgeColor}>
{formatNumber(migratedNodesCount, 'int_commas')}/{formatNumber(totalNodesCount, 'int_commas')}
</EuiBadge>
</EuiToolTip>
</EuiFlexItem>
);
}

return (
<ClusterItemContainer
{...props}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
EuiDescriptionListTitle,
EuiDescriptionListDescription,
EuiHorizontalRule,
EuiBadge,
EuiIcon,
EuiToolTip
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
Expand All @@ -39,32 +39,46 @@ export function KibanaPanel(props) {
const goToKibana = () => props.changeUrl('kibana');
const goToInstances = () => props.changeUrl('kibana/instances');

const setupModeKibanaData = get(setupMode.data, 'kibana');
let setupModeInstancesData = null;
if (setupMode.enabled && setupMode.data) {
const kibanaData = get(setupMode.data, 'kibana.byUuid');
const migratedNodesCount = Object.values(kibanaData).filter(node => node.isFullyMigrated).length;
const totalNodesCount = Object.values(kibanaData).length;
const {
totalUniqueInstanceCount,
totalUniqueFullyMigratedCount,
totalUniquePartiallyMigratedCount
} = setupModeKibanaData;
const allMonitoredByMetricbeat = totalUniqueInstanceCount > 0 &&
(totalUniqueFullyMigratedCount === totalUniqueInstanceCount || totalUniquePartiallyMigratedCount === totalUniqueInstanceCount);
const internalCollectionOn = totalUniquePartiallyMigratedCount > 0;
if (!allMonitoredByMetricbeat || internalCollectionOn) {
let tooltipText = null;

const badgeColor = migratedNodesCount === totalNodesCount
? 'secondary'
: 'danger';
if (!allMonitoredByMetricbeat) {
tooltipText = i18n.translate('xpack.monitoring.cluster.overview.kibanaPanel.setupModeNodesTooltip.oneInternal', {
defaultMessage: `There's at least one instance that isn't being monitored using Metricbeat. Click the flag
icon to visit the instances listing page and find out more information about the status of each instance.`
});
}
else if (internalCollectionOn) {
tooltipText = i18n.translate('xpack.monitoring.cluster.overview.kibanaPanel.setupModeNodesTooltip.disableInternal', {
defaultMessage: `All instances are being monitored using Metricbeat but internal collection still needs to be turned
off. Click the flag icon to visit the instances listing page and disable internal collection.`
});
}

setupModeInstancesData = (
<EuiFlexItem grow={false}>
<EuiToolTip
position="top"
content={i18n.translate('xpack.monitoring.cluster.overview.kibanaPanel.setupModeNodesTooltip', {
defaultMessage: `These numbers indicate how many detected monitored instances versus how many
detected total instances. If there are more detected instances than monitored instances, click
the instances link and you will be guided in how to setup monitoring for the missing node.`
})}
>
<EuiBadge color={badgeColor}>
{formatNumber(migratedNodesCount, 'int_commas')}/{formatNumber(totalNodesCount, 'int_commas')}
</EuiBadge>
</EuiToolTip>
</EuiFlexItem>
);
setupModeInstancesData = (
<EuiFlexItem grow={false}>
<EuiToolTip
position="top"
content={tooltipText}
>
<EuiLink onClick={goToInstances}>
<EuiIcon type="flag" color="warning"/>
</EuiLink>
</EuiToolTip>
</EuiFlexItem>
);
}
}

return (
Expand Down