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

[Alerting] Update internal API calls use new Alerting APIs #116939

Closed
ymao1 opened this issue Nov 1, 2021 · 2 comments · Fixed by #121048
Closed

[Alerting] Update internal API calls use new Alerting APIs #116939

ymao1 opened this issue Nov 1, 2021 · 2 comments · Fixed by #121048
Assignees
Labels
bug Fixes for quality problems that affect the customer experience estimate:small Small Estimated Level of Effort Feature:Alerting/RulesManagement Issues related to the Rules Management UX Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) technical debt Improvement of the software architecture and operational architecture

Comments

@ymao1
Copy link
Contributor

ymao1 commented Nov 1, 2021

There are still places in the code that call the legacy alerting APIs. Now that we are using telemetry to track usages of the legacy APIs, we should update to use the new ones so that the telemetry numbers are not thrown off.

useEffect(() => {
if (!alert) {
http.get(`${LEGACY_BASE_ALERT_API_PATH}/alert/${id}`).then(setAlert);
}
if (!alertState) {
http.get(`${LEGACY_BASE_ALERT_API_PATH}/alert/${id}/state`).then(setAlertState);
}
}, [alert, alertState, http, id]);

useEffect(() => {
if (!alert) {
http.get(`${LEGACY_BASE_ALERT_API_PATH}/alert/${id}`).then(setAlert);
}
if (!alertState) {
http.get(`${LEGACY_BASE_ALERT_API_PATH}/alert/${id}/state`).then(setAlertState);
}
}, [alert, alertState, http, id]);

export async function loadAlertType({
http,
id,
}: {
http: HttpSetup;
id: AlertType['id'];
}): Promise<AlertType | undefined> {
const alertTypes = (await http.get(
`${LEGACY_BASE_ALERT_API_PATH}/list_alert_types`
)) as AlertType[];
return alertTypes.find((type) => type.id === id);
}
export async function loadAlert({
http,
alertId,
}: {
http: HttpSetup;
alertId: string;
}): Promise<Alert> {
return await http.get(`${LEGACY_BASE_ALERT_API_PATH}/alert/${alertId}`);
}

@ymao1 ymao1 added Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) Feature:Alerting/RulesManagement Issues related to the Rules Management UX estimate:small Small Estimated Level of Effort labels Nov 1, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-alerting-services (Team:Alerting Services)

@gmmorris gmmorris added the technical debt Improvement of the software architecture and operational architecture label Nov 3, 2021
@mikecote mikecote added the bug Fixes for quality problems that affect the customer experience label Nov 3, 2021
@pmuellr pmuellr self-assigned this Nov 8, 2021
@pmuellr
Copy link
Member

pmuellr commented Nov 11, 2021

Took another peek at uses of LEGACY_BASE_ALERT_API_PATH, and it appears the only changes we need are in the three files Ying referenced.

There is a reference in stack monitoring code though:

async function disableAlert() {
setIsSaving(true);
try {
await Legacy.shims.http.post(`${LEGACY_BASE_ALERT_API_PATH}/alert/${alert.id}/_disable`);
} catch (err) {
Legacy.shims.toastNotifications.addDanger({
title: i18n.translate('xpack.monitoring.alerts.panel.disableAlert.errorTitle', {
defaultMessage: `Unable to disable rule`,
}),
text: err.message,
});
}
setIsSaving(false);
}
async function enableAlert() {

I'm wondering if there's some chance we would need this for cross-version monitoring or something, but ... seems unlikely to me.

That code was changed by us :-) in PR #93977

I assume we can change this from the old URL to the new URL, @elastic/stack-monitoring ? I'd have made the change so they'd get notified anyway, so thought I'd ping a little ahead ...

pmuellr added a commit to pmuellr/kibana that referenced this issue Nov 30, 2021
pmuellr added a commit to pmuellr/kibana that referenced this issue Dec 16, 2021
resolves elastic#116939

Removes the lingering calls to the legacy HTTP endpoints by internal
Kibana code.
pmuellr added a commit that referenced this issue Dec 16, 2021
resolves #116939

Removes the remaining calls to the legacy HTTP alerting endpoints by internal Kibana code.
@kobelb kobelb added the needs-team Issues missing a team label label Jan 31, 2022
@botelastic botelastic bot removed the needs-team Issues missing a team label label Jan 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience estimate:small Small Estimated Level of Effort Feature:Alerting/RulesManagement Issues related to the Rules Management UX Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) technical debt Improvement of the software architecture and operational architecture
Projects
None yet
6 participants