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

Feature/translate monitoring server #25195

Merged
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
c7ec189
Merge pull request #1 from elastic/master
Nox911 Sep 24, 2018
fa01b88
Merge pull request #2 from elastic/master
Nox911 Sep 27, 2018
70f6c7e
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Sep 27, 2018
68587a0
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Sep 28, 2018
42aa7d3
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 2, 2018
efeaefe
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 2, 2018
8a054ed
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 8, 2018
b0d1660
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 16, 2018
62b6ad1
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 17, 2018
acbad4b
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 18, 2018
a850650
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 22, 2018
0a200ce
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 25, 2018
b2a8244
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 29, 2018
b4b979e
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 30, 2018
d349a4f
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 31, 2018
ae285b9
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Nov 2, 2018
89c869b
Translate monitoring server(without metrics folder)
Nox911 Nov 6, 2018
37d79e6
Fix issue
Nox911 Nov 6, 2018
fa2acd8
Fix issues
Nox911 Nov 6, 2018
c05b38d
Fix issues
Nox911 Nov 9, 2018
6ec570e
Remove eslint rule disabling
maryia-lapata Nov 13, 2018
12bfdc1
Merge branch 'master' into feature/translate-monitoring-server
maryia-lapata Nov 13, 2018
a43a169
Merge branch 'master' into feature/translate-monitoring-server
maryia-lapata Nov 14, 2018
eb07ffc
Merge branch 'master' into feature/translate-monitoring-server
maryia-lapata Nov 21, 2018
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 @@ -7,6 +7,7 @@
import { get } from 'lodash';
import moment from 'moment';
import { verifyMonitoringLicense } from './verify_monitoring_license';
import { i18n } from '@kbn/i18n';

/**
* Retrieve any statically defined cluster alerts (not indexed) for the {@code cluster}.
Expand All @@ -32,8 +33,12 @@ export function staticAlertForCluster(cluster) {
},
update_timestamp: cluster.timestamp,
timestamp: get(cluster, 'license.issue_date', cluster.timestamp),
prefix: 'Configuring TLS will be required to apply a Gold or Platinum license when security is enabled.',
message: 'See documentation for details.'
prefix: i18n.translate('xpack.monitoring.clusterAlerts.clusterNeedsTSLEnabledDescription', {
defaultMessage: 'Configuring TLS will be required to apply a Gold or Platinum license when security is enabled.'
}),
message: i18n.translate('xpack.monitoring.clusterAlerts.seeDocumentationDescription', {
defaultMessage: 'See documentation for details.'
})
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import { get, find } from 'lodash';
import { verifyMonitoringLicense } from './verify_monitoring_license';
import { i18n } from '@kbn/i18n';

export function alertsClustersAggregation(req, alertsIndex, clusters, checkLicense) {
const verification = verifyMonitoringLicense(req.server);
Expand Down Expand Up @@ -105,7 +106,14 @@ export function alertsClustersAggregation(req, alertsIndex, clusters, checkLicen
alerts = {
clusterMeta: {
enabled: false,
message: `Cluster [${cluster.cluster_name}] license type [${license.type}] does not support Cluster Alerts` }
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
29 changes: 25 additions & 4 deletions x-pack/plugins/monitoring/server/cluster_alerts/check_license.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import { includes } from 'lodash';
import { i18n } from '@kbn/i18n';

/**
* Function to do the work of checking license for cluster alerts feature support
Expand All @@ -24,27 +25,47 @@ export function checkLicense(type, active, clusterSource, watcher = true) {
// Disabled because there is no license
if (!type) {
return Object.assign(licenseInfo, {
message: `Cluster Alerts are not displayed because the [${clusterSource}] cluster's license could not be determined.`
message: i18n.translate('xpack.monitoring.clusterAlerts.checkLicense.licenseNotDeterminedDescription', {
defaultMessage: `Cluster Alerts are not displayed because the [{clusterSource}] cluster's license could not be determined.`,
values: {
clusterSource
}
})
});
}

// Disabled because the license type is not valid (basic)
if (!includes([ 'trial', 'standard', 'gold', 'platinum' ], type)) {
return Object.assign(licenseInfo, {
message: `Cluster Alerts are not displayed if Watcher is disabled or the [${clusterSource}] cluster's current license is basic.`
message: i18n.translate('xpack.monitoring.clusterAlerts.checkLicense.licenseIsBasicDescription', {
//eslint-disable-next-line max-len
defaultMessage: `Cluster Alerts are not displayed if Watcher is disabled or the [{clusterSource}] cluster's current license is basic.`,
values: {
clusterSource
}
})
});
}

// Disabled because the license is inactive
if (!active) {
return Object.assign(licenseInfo, {
message: `Cluster Alerts are not displayed because the [${clusterSource}] cluster's current license [${type}] is not active.`
message: i18n.translate('xpack.monitoring.clusterAlerts.checkLicense.licenseNotActiveDescription', {
defaultMessage: `Cluster Alerts are not displayed because the [{clusterSource}] cluster's current license [{type}] is not active.`,
values: {
clusterSource,
type
}
})
});
}

// Disabled because Watcher is not enabled (it may or may not be available)
if (!watcher) {
return Object.assign(licenseInfo, { message: 'Cluster alerts is not enabled because Watcher is disabled.' });
return Object.assign(licenseInfo, {
message: i18n.translate('xpack.monitoring.clusterAlerts.checkLicense.watcherIsDisabledDescription', {
defaultMessage: 'Cluster alerts is not enabled because Watcher is disabled.' })
});
}

return Object.assign(licenseInfo, { clusterAlerts: { enabled: true } });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import { get } from 'lodash';
import { i18n } from '@kbn/i18n';

/**
* Determine if an API for Cluster Alerts should respond based on the license and configuration of the monitoring cluster.
Expand All @@ -31,12 +32,14 @@ export function verifyMonitoringLicense(server) {

return {
enabled: false,
message: 'Status of Cluster Alerts feature could not be determined.'
message: i18n.translate('xpack.monitoring.clusterAlerts.verifyMonitoringLicenseNotDeterminedDescription', {
Nox911 marked this conversation as resolved.
Show resolved Hide resolved
defaultMessage: 'Status of Cluster Alerts feature could not be determined.' })
};
}

return {
enabled: false,
message: 'Cluster Alerts feature is disabled.'
message: i18n.translate('xpack.monitoring.clusterAlerts.verifyMonitoringLicenseDisabledDescription', {
Nox911 marked this conversation as resolved.
Show resolved Hide resolved
defaultMessage: 'Cluster Alerts feature is disabled.' })
};
}
12 changes: 10 additions & 2 deletions x-pack/plugins/monitoring/server/lib/cluster/get_cluster_stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import { badRequest, notFound } from 'boom';
import { getClustersStats } from './get_clusters_stats';
import { i18n } from '@kbn/i18n';

/**
* This will fetch the cluster stats and cluster state as a single object for the cluster specified by the {@code req}.
Expand All @@ -17,14 +18,21 @@ import { getClustersStats } from './get_clusters_stats';
*/
export function getClusterStats(req, esIndexPattern, clusterUuid) {
if (!clusterUuid) {
throw badRequest('clusterUuid not specified');
throw badRequest(i18n.translate('xpack.monitoring.cluster.clusterStats.clusterUuidNotSpecifiedErrorMessage', {
Nox911 marked this conversation as resolved.
Show resolved Hide resolved
defaultMessage: 'clusterUuid not specified'
Nox911 marked this conversation as resolved.
Show resolved Hide resolved
}));
}

// passing clusterUuid so `get_clusters` will filter for single cluster
return getClustersStats(req, esIndexPattern, clusterUuid)
.then(clusters => {
if (!clusters || clusters.length === 0) {
throw notFound(`Unable to find the cluster in the selected time range. UUID: ${clusterUuid}`);
throw notFound(i18n.translate('xpack.monitoring.cluster.clusterStats.clusterUuidNotFoundErrorMessage', {
Nox911 marked this conversation as resolved.
Show resolved Hide resolved
defaultMessage: 'Unable to find the cluster in the selected time range. UUID: {clusterUuid}',
values: {
clusterUuid
}
}));
}

return clusters[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { checkLicense as checkLicenseForAlerts } from '../../cluster_alerts/chec
import { getClustersSummary } from './get_clusters_summary';
import { CLUSTER_ALERTS_SEARCH_SIZE } from '../../../common/constants';
import { getApmsForClusters } from '../apm/get_apms_for_clusters';
import { i18n } from '@kbn/i18n';

/**
* Get all clusters or the cluster associated with {@code clusterUuid} when it is defined.
Expand All @@ -39,7 +40,12 @@ export async function getClustersFromRequest(req, indexPatterns, { clusterUuid,
// TODO: this handling logic should be two different functions
if (clusterUuid) { // if is defined, get specific cluster (no need for license checking)
if (!clusters || clusters.length === 0) {
throw notFound(`Unable to find the cluster in the selected time range. UUID: ${clusterUuid}`);
throw notFound(i18n.translate('xpack.monitoring.cluster.clustersFromRequest.clusterUuidNotFoundErrorMessage', {
Nox911 marked this conversation as resolved.
Show resolved Hide resolved
defaultMessage: 'Unable to find the cluster in the selected time range. UUID: {clusterUuid}',
values: {
clusterUuid
}
}));
}

const cluster = clusters[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { get } from 'lodash';
import { checkParam } from '../../error_missing_required';
import { createQuery } from '../../create_query';
import { ElasticsearchMetric } from '../../metrics';
import { i18n } from '@kbn/i18n';

export function handleResponse(shardStats, indexUuid) {
return response => {
Expand All @@ -31,10 +32,13 @@ export function handleResponse(shardStats, indexUuid) {
indexSummary = {
unassignedShards,
totalShards: get(_shardStats, 'primary', 0) + get(_shardStats, 'replica', 0) + unassignedShards,
status: _shardStats.status || 'Unknown',
status: _shardStats.status || i18n.translate('xpack.monitoring.es.indices.unknownStatusLabel', {
defaultMessage: 'Unknown' })
};
} else {
indexSummary = { status: 'Not Available', };
indexSummary = { status: i18n.translate('xpack.monitoring.es.indices.notAvailableStatusLabel', {
defaultMessage: 'Not Available' })
};
}

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ElasticsearchMetric } from '../../metrics';
import { createQuery } from '../../create_query';
import { calculateRate } from '../../calculate_rate';
import { getUnassignedShards } from '../shards';
import { i18n } from '@kbn/i18n';

export function handleResponse(resp, min, max, shardStats) {
// map the hits
Expand Down Expand Up @@ -57,7 +58,8 @@ export function handleResponse(resp, min, max, shardStats) {
statusSort = 3;
}
} else {
status = 'Deleted / Closed';
status = i18n.translate('xpack.monitoring.es.indices.deletedClosedStatusLabel', {
defaultMessage: 'Deleted / Closed' });
statusSort = 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { ElasticsearchMetric } from '../../metrics';
import { getDefaultNodeFromId } from './get_default_node_from_id';
import { calculateNodeType } from './calculate_node_type';
import { getNodeTypeClassLabel } from './get_node_type_class_label';
import { i18n } from '@kbn/i18n';

export function handleResponse(clusterState, shardStats, nodeUuid) {
return response => {
Expand Down Expand Up @@ -44,13 +45,16 @@ export function handleResponse(clusterState, shardStats, nodeUuid) {
dataSize: get(sourceStats, 'indices.store.size_in_bytes'),
freeSpace: get(sourceStats, 'fs.total.available_in_bytes'),
usedHeap: get(sourceStats, 'jvm.mem.heap_used_percent'),
status: 'Online',
status: i18n.translate('xpack.monitoring.es.nodes.onlineStatusLabel', {
defaultMessage: 'Online' }),
isOnline: true,
};
} else {
nodeSummary = {
nodeTypeLabel: 'Offline Node',
status: 'Offline',
nodeTypeLabel: i18n.translate('xpack.monitoring.es.nodes.offlineNodeStatusLabel', {
defaultMessage: 'Offline Node' }),
status: i18n.translate('xpack.monitoring.es.nodes.offlineStatusLabel', {
defaultMessage: 'Offline' }),
isOnline: false,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
* Note: currently only `node` and `master` are supported due to
* https://github.com/elastic/x-pack-kibana/issues/608
*/

import { i18n } from '@kbn/i18n';

export const nodeTypeClass = {
invalid: 'fa-exclamation-triangle',
node: 'fa-server',
Expand All @@ -18,10 +21,16 @@ export const nodeTypeClass = {
};

export const nodeTypeLabel = {
invalid: 'Invalid Node',
node: 'Node',
master: 'Master Node',
master_only: 'Master Only Node',
data: 'Data Only Node',
client: 'Client Node'
invalid: i18n.translate('xpack.monitoring.es.nodes.nodeType.invalidNodeLabel', {
Nox911 marked this conversation as resolved.
Show resolved Hide resolved
defaultMessage: 'Invalid Node' }),
node: i18n.translate('xpack.monitoring.es.nodes.nodeType.nodeLabel', {
defaultMessage: 'Node' }),
master: i18n.translate('xpack.monitoring.es.nodes.nodeType.masterNodeLabel', {
defaultMessage: 'Master Node' }),
master_only: i18n.translate('xpack.monitoring.es.nodes.nodeType.masterOnlyNodeLabel', {
defaultMessage: 'Master Only Node' }),
data: i18n.translate('xpack.monitoring.es.nodes.nodeType.dataOnlyNodeLabel', {
defaultMessage: 'Data Only Node' }),
client: i18n.translate('xpack.monitoring.es.nodes.nodeType.clientNodeLabel', {
defaultMessage: 'Client Node' })
};
7 changes: 5 additions & 2 deletions x-pack/plugins/monitoring/server/lib/errors/auth_errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import { forbidden } from 'boom';
import { i18n } from '@kbn/i18n';

const getStatusCode = err => {
return err.isBoom ? err.output.statusCode : err.statusCode;
Expand All @@ -26,9 +27,11 @@ export function handleAuthError(err) {
* connection but not the monitoring connection
*/
if (statusCode === 401) {
message = 'Invalid authentication for monitoring cluster';
message = i18n.translate('xpack.monitoring.errors.invalidAuthErrorMessage', {
defaultMessage: 'Invalid authentication for monitoring cluster' });
} else {
message = 'Insufficient user permissions for monitoring data';
message = i18n.translate('xpack.monitoring.errors.insufficientUserErrorMessage', {
defaultMessage: 'Insufficient user permissions for monitoring data' });
}

return forbidden(message);
Expand Down
11 changes: 7 additions & 4 deletions x-pack/plugins/monitoring/server/lib/errors/known_errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { boomify } from 'boom';

import { i18n } from '@kbn/i18n';
/*
* Check if the given error message is a known "safe" type of error
* in which case we want to give the status as 503 and show the error message.
Expand All @@ -17,9 +17,12 @@ import { boomify } from 'boom';
const KNOWN_ERROR_STATUS_CODE = 503;

const mapTypeMessage = {
ConnectionFault: 'Check the Elasticsearch Monitoring cluster network connection and refer to the Kibana logs for more information.',
NoConnections: 'Check the Elasticsearch Monitoring cluster network connection and refer to the Kibana logs for more information.',
StatusCodeError: 'Check the Elasticsearch Monitoring cluster network connection or the load level of the nodes.'
ConnectionFault: i18n.translate('xpack.monitoring.errors.connectionFaultErrorMessage', {
defaultMessage: 'Check the Elasticsearch Monitoring cluster network connection and refer to the Kibana logs for more information.' }),
NoConnections: i18n.translate('xpack.monitoring.errors.noConnectionsErrorMessage', {
defaultMessage: 'Check the Elasticsearch Monitoring cluster network connection and refer to the Kibana logs for more information.' }),
StatusCodeError: i18n.translate('xpack.monitoring.errors.statusCodeErrorMessage', {
defaultMessage: 'Check the Elasticsearch Monitoring cluster network connection or the load level of the nodes.' })
};

export function isKnownError(err) {
Expand Down