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

[Infrastructure UI][Rules] Add recovery context to the Metric Threshold rule #131264

Expand Up @@ -246,6 +246,23 @@ export const createMetricThresholdExecutor = (libs: InfraBackendLibs) =>
});
}
}

simianhacker marked this conversation as resolved.
Show resolved Hide resolved
const { getRecoveredAlerts } = services.alertFactory.done();
const recoveredAlerts = getRecoveredAlerts();
for (const alert of recoveredAlerts) {
const recoveredAlertId = alert.getId();
const viewInAppUrl = getViewInAppUrl(libs.basePath, LINK_TO_METRICS_EXPLORER);
const context = {
group: recoveredAlertId,
simianhacker marked this conversation as resolved.
Show resolved Hide resolved
alertState: stateToAlertMessage[AlertStates.OK],
timestamp: startedAt.toISOString(),
viewInAppUrl,
threshold: mapToConditionsLookup(criteria, (c) => c.threshold),
metric: mapToConditionsLookup(criteria, (c) => c.metric),
};
alert.setContext(context);
}

const stopTime = Date.now();
logger.debug(`Scheduled ${scheduledActionsCount} actions in ${stopTime - startTime}ms`);
return {
Expand Down
Expand Up @@ -89,6 +89,7 @@ export async function registerMetricThresholdRuleType(
minimumLicenseRequired: 'basic',
isExportable: true,
executor: createMetricThresholdExecutor(libs),
doesSetRecoveryContext: true,
actionVariables: {
context: [
{ name: 'group', description: groupActionVariableDescription },
Expand Down