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

[Uptime] migrate to observability rules registry #100699

Conversation

dominiqueclarke
Copy link
Contributor

@dominiqueclarke dominiqueclarke commented May 26, 2021

Fixes #98382

This PR registers uptime alerts in the new rules registry by taking the following steps.

  1. Registering our index templates and server side rule types in the sever plugin.ts
  2. Registering our rule types in the public plugin.ts
  3. Calling the new alertWithLifecycle service passing along with relevant fields to populate our alerts in the Observability alerts table
  4. Adjusting our public rule types to pass the reason and link field to integrate with the Observability alerts table UI.

Author Checklist

  • Accessibility has been considered, relevant aria tags and other accessibility features implemented
    note: This feature is purely technical in nature, and does not directly touch UI elements that need accessibility considerations.
  • Telemetry has been added where relevant @justinkambic @shahzad31 Do we currently have telemetry in place for alerts?
  • Docs have been added to this PR covering any new, changed, or removed features
  • Testing for expected behavior is in place
    • Automated tests exist to cover expected and edge case conditions
    • User acceptance testing has been carried out to ensure the feature functions as expected within the context of how it will be used
    • Any special/edge cases that need to be manually tested must be documented
    • Ensure the new layout works responsively (including down to small phone widths, where makes sense for the user flow, e.g. the error page when reacting to an alert)

Reviewer Checklist

  • Accessibility has been considered, relevant aria tags and other accessibility features implemented
  • Telemetry has been added where relevant
  • Docs have been added to this PR covering any new, changed, or removed features
  • Testing for expected behavior is in place
    • Automated tests exist to cover expected and edge case conditions
    • User acceptance testing has been carried out to ensure the feature functions as expected within the context of how it will be used
    • Any special/edge cases that need to be manually tested must be documented
    • Ensure the new layout works responsively (including down to small phone widths, where makes sense for the user flow, e.g. the error page when reacting to an alert)

Testing

kibana.dev.yaml keys

xpack.ruleRegistry.index: '.kibana-alerts'
xpack.ruleRegistry.write.enabled: true

[ ] - Ensure that rules appear on the Observability alerts table found at /app/observability/alerts
[ ] - Ensure that reason is configured correctly in the Observability alerts table
[ ] - Ensure that View in App from the Observability alerts table takes you to the correct context in Uptime
[ ] - Smoke test that action connectors are appropriately sending alert messages
[ ] - Smoke test that the rules are appearing appropriately in the rules and connectors page.

Edge case

[ ] - Smoke test that the legacy Uptime TLS rule still works as expected, by configuring it from the Rules and Connectors page, which is the only place it should be accessible. Ensure that this rule does not appear in the Observability alerts table

@dominiqueclarke dominiqueclarke added enhancement New value added to drive a business result v8.0.0 Team:Uptime - DEPRECATED Synthetics & RUM sub-team of Application Observability release_note:skip Skip the PR/issue when compiling release notes v7.14.0 auto-backport Deprecated - use backport:version if exact versions are needed labels May 26, 2021
@dominiqueclarke dominiqueclarke requested a review from a team as a code owner May 26, 2021 16:03
@elasticmachine
Copy link
Contributor

Pinging @elastic/uptime (Team:uptime)

@dominiqueclarke dominiqueclarke marked this pull request as draft May 26, 2021 16:04
@@ -37,3 +37,60 @@ export const MonitorStatusTranslations = {
defaultMessage: 'Alert when a monitor is down or an availability threshold is breached.',
}),
};

export const TlsTranslations = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved alert translations to common, in order to use them within server to derive reason message.

@@ -30,4 +32,8 @@ export const initDurationAnomalyAlertType: AlertTypeInitializer = ({
validate: () => ({ errors: {} }),
defaultActionMessage,
requiresAppContext: true,
format: ({ alert }) => ({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

draft.

@@ -27,7 +27,7 @@ export const SettingsMessageExpressionPopover: React.FC<SettingsMessageExpressio
id,
}) => {
const kibana = useKibana();
const path = kibana.services?.application?.getUrlForApp('uptime', { path: 'settings' });
const settingsPath = kibana.services?.http?.basePath.prepend('uptime/settings');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because alerts are registered in the setup function, this component no longer has access to getUrlForApp.

type: 'keyword',
},
// tls alert fields
'cert.count': {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@shahzad31 We can't use the ecs fields here, since the fields represent a single instance of a cert, but these are meant to represent all the found expiring/aging certs to the entire alert. (Also this is supposed to be cert_status.count, like the rest of the items below).

Copy link
Contributor

Choose a reason for hiding this comment

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

++ that makes senese

@dominiqueclarke
Copy link
Contributor Author

@elasticmachine merge upstream

@shahzad31
Copy link
Contributor

just noticed this , description is inverted
image

Copy link
Contributor

@shahzad31 shahzad31 left a comment

Choose a reason for hiding this comment

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

Looks good can see the alerts and code looks good as well. !!

Copy link
Contributor

@justinkambic justinkambic left a comment

Choose a reason for hiding this comment

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

LGTM, tested this out with a few basic alerts and didn't see any red flags.

const { anomalies } =
(await getAnomalies(plugins, savedObjectsClient, params, state.lastCheckedAt)) ?? {};
if (foundAnomalies) {
const monitorInfo = await libs.requests.getLatestMonitor({
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know if there was a particular reason we were doing it as a direct import. Given that we are supplying all the dependencies in either case, I think it doesn't hurt to use the libs version.

@dominiqueclarke
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
ruleRegistry 58 60 +2

Async chunks

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

id before after diff
uptime 949.7KB 946.5KB -3.2KB

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
ruleRegistry 10 9 -1

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
uptime 22.7KB 29.3KB +6.6KB
Unknown metric groups

API count

id before after diff
ruleRegistry 58 60 +2

History

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

Copy link
Contributor

@justinkambic justinkambic left a comment

Choose a reason for hiding this comment

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

Tested this again with some more alerts. LGTM

@dominiqueclarke dominiqueclarke merged commit 743c8c2 into elastic:master Jul 16, 2021
@dominiqueclarke dominiqueclarke deleted the feature/98382-uptime-migrate-to-observability-rules-registry branch July 16, 2021 19:34
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Jul 16, 2021
* uptime - migrate to observability rules registry

* Modify Uptime alert types to work with server rule registry.

* Export `RuleType` type for consumption by client plugins.

* Add platinum as an option for `minimumLicenseRequired` field of `RuleTypeBase`.

* Simplify alert bootstrapping, inherit `RuleType` for alert factories.

* update rule field map

* adjust rule registery to be created within setup instead of mount

* adjust plugin setup to account for rule registry changes

* export types from rule registry

* move alert action message translations to common

* update rule field map

* update monitor status public alert model

* update tls public alert model

* update monitor status alert server model

* update tls alert sever model

* update server plugin file to scope alerts indices to synthetics

* add initContext to server Plugin class

* adjust public plugin to register alerts when core start is availabile

* update mappings

* update asset names

* adjust dependencies for alert initialization

* adjust duration anomaly server alert model

* adjust duration anomaly and monitor status public alert model to account for undefined types

* add duration_anomaly tests

* add anomaly severity

* adjust types

* update uptime server plugin

* remove test_helpers

* add getMonitorRouteFromMonitorId helper

* export AlertTypeWithExecutor from rule_registry

* adjust types

* mock time zone

* update types

* update types for legacy tls alert

* update mappings

* update monitor status check tls types

* update tls types and indexed fields

* update duration anomaly types and indexed fields

* update mappings

* delete unnecessary file

* adjust types

* adjust ruleDataClient initialization

* index anomaly bucket span

* update types

* adjust registration of legacy tls alert type

* adjust types

* update index alias name

* update anomaly detection rule mappings

* adjust import for certificate alert

* adjust rbac settings

* adjust content

* adjust uptime server plugin

Co-authored-by: Justin Kambic <justin.kambic@elastic.co>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
@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 Jul 16, 2021
* uptime - migrate to observability rules registry

* Modify Uptime alert types to work with server rule registry.

* Export `RuleType` type for consumption by client plugins.

* Add platinum as an option for `minimumLicenseRequired` field of `RuleTypeBase`.

* Simplify alert bootstrapping, inherit `RuleType` for alert factories.

* update rule field map

* adjust rule registery to be created within setup instead of mount

* adjust plugin setup to account for rule registry changes

* export types from rule registry

* move alert action message translations to common

* update rule field map

* update monitor status public alert model

* update tls public alert model

* update monitor status alert server model

* update tls alert sever model

* update server plugin file to scope alerts indices to synthetics

* add initContext to server Plugin class

* adjust public plugin to register alerts when core start is availabile

* update mappings

* update asset names

* adjust dependencies for alert initialization

* adjust duration anomaly server alert model

* adjust duration anomaly and monitor status public alert model to account for undefined types

* add duration_anomaly tests

* add anomaly severity

* adjust types

* update uptime server plugin

* remove test_helpers

* add getMonitorRouteFromMonitorId helper

* export AlertTypeWithExecutor from rule_registry

* adjust types

* mock time zone

* update types

* update types for legacy tls alert

* update mappings

* update monitor status check tls types

* update tls types and indexed fields

* update duration anomaly types and indexed fields

* update mappings

* delete unnecessary file

* adjust types

* adjust ruleDataClient initialization

* index anomaly bucket span

* update types

* adjust registration of legacy tls alert type

* adjust types

* update index alias name

* update anomaly detection rule mappings

* adjust import for certificate alert

* adjust rbac settings

* adjust content

* adjust uptime server plugin

Co-authored-by: Justin Kambic <justin.kambic@elastic.co>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Dominique Clarke <doclarke71@gmail.com>
Co-authored-by: Justin Kambic <justin.kambic@elastic.co>
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 enhancement New value added to drive a business result release_note:skip Skip the PR/issue when compiling release notes Team:Uptime - DEPRECATED Synthetics & RUM sub-team of Application Observability v7.15.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RAC] [Uptime UI] Register Uptime UI rule type(s) with new RAC rules registry
8 participants