Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisronline committed Oct 1, 2020
1 parent 490dac0 commit c262c6a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
AlertMissingData,
AlertMessageTimeToken,
AlertInstanceState,
AlertMessageLinkToken,
} from './types';
import { AlertInstance, AlertServices } from '../../../alerts/server';
import {
Expand All @@ -42,6 +41,7 @@ import { getListingLinkForStackProduct } from '../lib/alerts/get_listing_link_fo
import { getStackProductLabel } from '../lib/alerts/get_stack_product_label';
import { fetchClusters } from '../lib/alerts/fetch_clusters';
import { fetchAvailableCcs } from '../lib/alerts/fetch_available_ccs';
import { AlertingDefaults, createLink } from './alerts_common';

const RESOLVED = i18n.translate('xpack.monitoring.alerts.missingData.resolved', {
defaultMessage: 'resolved',
Expand Down Expand Up @@ -88,30 +88,6 @@ export class MissingMonitoringDataAlert extends BaseAlert {
};

protected actionVariables = [
{
name: 'internalShortMessage',
description: i18n.translate(
'xpack.monitoring.alerts.missingData.actionVariables.internalShortMessage',
{
defaultMessage: 'The short internal message generated by Elastic.',
}
),
},
{
name: 'internalFullMessage',
description: i18n.translate(
'xpack.monitoring.alerts.missingData.actionVariables.internalFullMessage',
{
defaultMessage: 'The full internal message generated by Elastic.',
}
),
},
{
name: 'state',
description: i18n.translate('xpack.monitoring.alerts.missingData.actionVariables.state', {
defaultMessage: 'The current state of the alert.',
}),
},
{
name: 'stackProducts',
description: i18n.translate(
Expand All @@ -127,30 +103,7 @@ export class MissingMonitoringDataAlert extends BaseAlert {
defaultMessage: 'The number of stack products missing monitoring data.',
}),
},
{
name: 'clusterName',
description: i18n.translate(
'xpack.monitoring.alerts.missingData.actionVariables.clusterName',
{
defaultMessage: 'The cluster to which the stack products belong.',
}
),
},
{
name: 'action',
description: i18n.translate('xpack.monitoring.alerts.missingData.actionVariables.action', {
defaultMessage: 'The recommended action for this alert.',
}),
},
{
name: 'actionPlain',
description: i18n.translate(
'xpack.monitoring.alerts.missingData.actionVariables.actionPlain',
{
defaultMessage: 'The recommended action for this alert, without any markdown.',
}
),
},
...Object.values(AlertingDefaults.ALERT_TYPE.context),
];

protected async fetchClusters(
Expand Down Expand Up @@ -197,7 +150,6 @@ export class MissingMonitoringDataAlert extends BaseAlert {
callCluster,
clusters,
indexPattern,
limit,
this.config.ui.max_bucket_size,
now,
now - limit - LIMIT_BUFFER
Expand Down Expand Up @@ -271,10 +223,6 @@ export class MissingMonitoringDataAlert extends BaseAlert {

protected getUiMessage(alertState: AlertState, item: AlertData): AlertMessage {
const { missing, limit } = item.meta as { missing: AlertMissingData; limit: number };
const globalState = [`cluster_uuid:${item.clusterUuid}`];
if (item.ccs) {
globalState.push(`ccs:${item.ccs}`);
}
if (!alertState.ui.isFiring) {
if (missing.gapDuration > limit) {
return {
Expand Down Expand Up @@ -319,27 +267,19 @@ export class MissingMonitoringDataAlert extends BaseAlert {
},
}),
nextSteps: [
{
text: i18n.translate('xpack.monitoring.alerts.missingData.ui.nextSteps.hotThreads', {
createLink(
i18n.translate('xpack.monitoring.alerts.missingData.ui.nextSteps.viewAll', {
defaultMessage: `#start_linkView all {stackProduct} {type}#end_link`,
values: {
type: getTypeLabelForStackProduct(missing.stackProduct),
stackProduct: getStackProductLabel(missing.stackProduct),
},
}),
tokens: [
{
startToken: '#start_link',
endToken: '#end_link',
type: AlertMessageTokenType.Link,
url: `${getListingLinkForStackProduct(missing.stackProduct)}?_g=(${globalState.join(
','
)})`,
} as AlertMessageLinkToken,
],
},
getListingLinkForStackProduct(missing.stackProduct),
AlertMessageTokenType.Link
),
{
text: i18n.translate('xpack.monitoring.alerts.missingData.ui.nextSteps.runningTasks', {
text: i18n.translate('xpack.monitoring.alerts.missingData.ui.nextSteps.verifySettings', {
defaultMessage: `Verify monitoring settings on the {type}`,
values: {
type: getTypeLabelForStackProduct(missing.stackProduct, false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function getResponse(
describe('fetchMissingMonitoringData', () => {
let callCluster = jest.fn();
const index = '.monitoring-*';
const limit = 100;
const startMs = 100;
const size = 10;

it('fetch as expected', async () => {
Expand Down Expand Up @@ -137,7 +137,14 @@ describe('fetchMissingMonitoringData', () => {
},
};
});
const result = await fetchMissingMonitoringData(callCluster, clusters, index, limit, size, now);
const result = await fetchMissingMonitoringData(
callCluster,
clusters,
index,
size,
now,
startMs
);
expect(result).toEqual([
{
stackProduct: 'elasticsearch',
Expand Down Expand Up @@ -220,7 +227,14 @@ describe('fetchMissingMonitoringData', () => {
},
};
});
const result = await fetchMissingMonitoringData(callCluster, clusters, index, limit, size, now);
const result = await fetchMissingMonitoringData(
callCluster,
clusters,
index,
size,
now,
startMs
);
expect(result).toEqual([
{
stackProduct: 'elasticsearch',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ export async function fetchMissingMonitoringData(
callCluster: any,
clusters: AlertCluster[],
index: string,
limit: number,
size: number,
nowInMs: number,
startMs: number
Expand Down

0 comments on commit c262c6a

Please sign in to comment.