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

[Observability] Remove outdated top_alerts route and related types #107579

Merged
merged 24 commits into from
Aug 12, 2021

Conversation

weltenwort
Copy link
Member

@weltenwort weltenwort commented Aug 3, 2021

📝 Summary

This removes the AlertsTable, which has since been replaced with a "timeline grid"-based implementation. Along with that it removes the observability-specific "top alerts" HTTP API, which has been replaced with the "timeline" search strategy used internally by the timeline grid.

closes #104927

🕵️ Review notes

  • APM code owners: This removes parts of tests located in APM that queried the removed API. It also removes the type import of the implicit route handler return value, because the timeline search strategy doesn't provide that amount of type safety. To mitigate that the parseAlert function decodes the alert documents (similar to decorateResponse before).
  • The story for the alerts table apparently became mostly a no-op story when the t-grid was introduced. This PR doesn't fix it, but removes references to the removed API and types so it renders without errors.

@weltenwort weltenwort added v8.0.0 Team:Infra Monitoring UI - DEPRECATED DEPRECATED - Label for the Infra Monitoring UI team. Use Team:obs-ux-infra_services release_note:skip Skip the PR/issue when compiling release notes auto-backport Deprecated - use backport:version if exact versions are needed Theme: rac label obsolete Feature:RAC label obsolete v7.15.0 Feature:Observability RAC labels Aug 3, 2021
@weltenwort weltenwort self-assigned this Aug 3, 2021
if (endpoint === '/api/observability/rules/alerts/top') {
return items;
} else if (endpoint === '/api/observability/rules/alerts/dynamic_index_pattern') {
if (endpoint === '/api/observability/rules/alerts/dynamic_index_pattern') {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this doesn't fix the story but it also doesn't break it further. But IMHO it would exceed the scope of the PR to implement a working t-grid mock.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the story isn't doing doing anything we should just delete it.

import { SeverityBadge } from '../severity_badge';

type AlertsFlyoutProps = {
alert?: TopAlert;
alerts?: TopAlertResponse[];
alerts?: Array<Record<string, unknown>>;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TopAlertResponse was only every indirectly defined via the return type of the server-side route registration. The removal of that route meant the type went away as well. The data fetching now happens via the timeline search strategy, which doesn't provide much type safety around the data, which is reflected by this Record<string, unknown>. The object is decoded using parseAlert anyway (which is the successor to decorateResponse).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if we don't have much type safety now, would it make sense to extract Record<string, unknown> to a separate type? That way if/when we get better typings it's a simpler change

import { ObservabilityRuleTypeRegistry } from '../../rules/create_observability_rule_type_registry';

export const parseAlert = (observabilityRuleTypeRegistry: ObservabilityRuleTypeRegistry) => (
alert: Record<string, unknown>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the successor to decorateResponse, whose argument type TopAlertResponse was only every indirectly defined via the return type of the server-side route registration. The removal of that route meant the type went away as well. The data fetching now happens via the timeline search strategy, which doesn't provide much type safety around the data, which is reflected by this Record<string, unknown>.

const { body: topAlerts, status: topAlertStatus } = await supertest
.get(
format({
pathname: '/api/observability/rules/alerts/top',
Copy link
Member Author

@weltenwort weltenwort Aug 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this was part of the APM api integration tests, but with the removal of that route this test won't work anymore. I don't think it's reasonable to query the timeline search strategy in here instead, so we'll have to rely on the ES document checks above.

@weltenwort weltenwort marked this pull request as ready for review August 5, 2021 15:46
@weltenwort weltenwort requested a review from a team as a code owner August 5, 2021 15:46
@elasticmachine
Copy link
Contributor

Pinging @elastic/logs-metrics-ui (Team:logs-metrics-ui)

@weltenwort weltenwort requested a review from a team August 5, 2021 15:46
@afgomez afgomez self-requested a review August 10, 2021 13:44
Copy link
Contributor

@afgomez afgomez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks alright! I left a small comment but we can track it afterwards

import { SeverityBadge } from '../severity_badge';

type AlertsFlyoutProps = {
alert?: TopAlert;
alerts?: TopAlertResponse[];
alerts?: Array<Record<string, unknown>>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if we don't have much type safety now, would it make sense to extract Record<string, unknown> to a separate type? That way if/when we get better typings it's a simpler change

@weltenwort
Copy link
Member Author

weltenwort commented Aug 11, 2021

@afgomez I hope to have addressed your feedback, thank you for the review!

@afgomez
Copy link
Contributor

afgomez commented Aug 11, 2021

Thank you @weltenwort !

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
observability 479.2KB 479.3KB +160.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @weltenwort

@weltenwort weltenwort merged commit 45b33ba into elastic:master Aug 12, 2021
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Aug 12, 2021
…lastic#107579)

* Remove outdated top_alerts route and related types

* Remove tests for deleted code

* Remove test for deleted API

* Remove reference to deleted type

* Remove unused translations

* Remove unused mock from story

* Remove no-op alerts page story for now

* Remove unsafe type assertions

* Factor out alert field type

* Compile kbn-io-ts-utils for the browser as well

* Avoid deep import which doesn't work cross-platform

* Revert "Avoid deep import which doesn't work cross-platform"

This reverts commit 492378c.

* Revert "Compile kbn-io-ts-utils for the browser as well"

This reverts commit a1267b1.

* Revert "Factor out alert field type"

This reverts commit def6987.

* Revert "Remove unsafe type assertions"

This reverts commit c88d4cd.

* Remove unsafe type assertions (again)
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.x

This backport PR will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Aug 12, 2021
…107579) (#108452)

* Remove outdated top_alerts route and related types

* Remove tests for deleted code

* Remove test for deleted API

* Remove reference to deleted type

* Remove unused translations

* Remove unused mock from story

* Remove no-op alerts page story for now

* Remove unsafe type assertions

* Factor out alert field type

* Compile kbn-io-ts-utils for the browser as well

* Avoid deep import which doesn't work cross-platform

* Revert "Avoid deep import which doesn't work cross-platform"

This reverts commit 492378c.

* Revert "Compile kbn-io-ts-utils for the browser as well"

This reverts commit a1267b1.

* Revert "Factor out alert field type"

This reverts commit def6987.

* Revert "Remove unsafe type assertions"

This reverts commit c88d4cd.

* Remove unsafe type assertions (again)

Co-authored-by: Felix Stürmer <weltenwort@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed Feature:Observability RAC Feature:RAC label obsolete release_note:skip Skip the PR/issue when compiling release notes Team:Infra Monitoring UI - DEPRECATED DEPRECATED - Label for the Infra Monitoring UI team. Use Team:obs-ux-infra_services Theme: rac label obsolete v7.15.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RAC] Remove observability plugin alerts endpoint(s)
5 participants