-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
[Observability] Remove outdated top_alerts route and related types #107579
Conversation
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') { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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>>; |
There was a problem hiding this comment.
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
).
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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.
Pinging @elastic/logs-metrics-ui (Team:logs-metrics-ui) |
There was a problem hiding this 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>>; |
There was a problem hiding this comment.
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
x-pack/plugins/observability/public/pages/alerts/parse_alert.ts
Outdated
Show resolved
Hide resolved
@afgomez I hope to have addressed your feedback, thank you for the review! |
Thank you @weltenwort ! |
💚 Build Succeeded
Metrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: cc @weltenwort |
…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)
💚 Backport successful
This backport PR will be merged automatically after passing CI. |
…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>
📝 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
parseAlert
function decodes the alert documents (similar todecorateResponse
before).