-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Logs UI] Register log threshold rule as lifecycle rule #104341
[Logs UI] Register log threshold rule as lifecycle rule #104341
Conversation
x-pack/plugins/infra/public/alerting/log_threshold/rule_data_formatters.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/infra/public/alerting/log_threshold/rule_data_formatters.ts
Show resolved
Hide resolved
x-pack/plugins/rule_registry/server/utils/create_lifecycle_rule_type_factory.ts
Show resolved
Hide resolved
Pinging @elastic/logs-metrics-ui (Team:logs-metrics-ui) |
Pinging @elastic/apm-ui (Team:apm) |
@elasticmachine merge upstream |
@mgiota I've changed the copy of the ratio reason. This should be ready for another (hopefully final) look. |
💚 Build SucceededMetrics [docs]Module Count
Public APIs missing comments
Async chunks
Public APIs missing exports
Page load bundle
Unknown metric groupsAPI count
History
To update your PR or re-run it, just comment with: cc @weltenwort |
|
||
const ruleExecutorData = getRuleData(options); | ||
|
||
const state = getOrElse( |
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.
@weltenwort I see you refactored this part. My understanding is that this refactoring was done to accommodate generic values. I don't fully understand the isLeft
part in the initial code, so can you verify that the refactored code has the same result as before?
const decodedState = wrappedStateRt.decode(previousState);
const state = isLeft(decodedState)
? {
wrapped: previousState,
trackedAlerts: {},
}
: decodedState.right;
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.
isLeft
will return true
if the value could not be decoded ("left"). In that case, we wrap the state returned by the wrapped executor. If it can be successfully decoded ("right"), we know that it is a state managed by the wrapper, so we return it as-is.
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.
@dgieselaar Thanks for clarification!
@weltenwort I created a log threshold rule type and here's what I got regarding |
@weltenwort I did a few tests:
|
[logThresholdRuleDataNamespace]: { | ||
properties: { | ||
serialized_params: { | ||
type: 'keyword', |
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.
out of curiosity, why is this a keyword?
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.
type: "keyword"
and index: false
seemed to be the most parsimonious field configuration that doesn't cause a mapping explosion but is retrievable via fields
(which is what the alerts table search strategy uses). I would have preferred type: "object"
and enabled: false
, but then the field can't be retrieved via fields
.
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.
@afgomez Back in this PR Could this be related to the issue you have been discussing with @jasonrhodes #113003 ?
I didn't completely follow up the discussion you had there, I just though it might be worth mentioning that Felix was indexing params in this PR (https://github.com/elastic/kibana/pull/104341/files?file-filters%5B%5D=.ts#diff-4b27f4f59bd7ebc79225d9e379a663944592f8595e811a156ea75f66dfba679a) that you might want to have a look at.
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.
@mgiota thanks! It seems this code has been removed since this PR was merged though
@@ -9,9 +9,14 @@ | |||
* registering a new instance of the rule data client | |||
* in a new plugin will require updating the below data structure | |||
* to include the index name where the alerts as data will be written to. | |||
* | |||
* This doesn't work in combination with the `xpack.ruleRegistry.index` | |||
* setting, with which the user can change the index prefix. | |||
*/ | |||
export const mapConsumerToIndexName = { | |||
apm: '.alerts-observability-apm', |
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.
should this be changed to .alerts-observability.apm
?
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.
Yes, but it's not what this PR is about. It needs to be changed in multiple places. It's tracked in #102089.
@@ -37,3 +38,14 @@ export function getRuleExecutorData( | |||
[PRODUCER]: type.producer, | |||
}; | |||
} | |||
|
|||
export function getRuleData(options: AlertExecutorOptions<any, any, any, any, any>) { |
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.
do we still need the other function based on the rule type definition? (getRuleExecutorData
)
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.
Good point, I forgot to remove it 👍
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.
looks good! I do hope that we can clean up the types at some point.
@mgiota thanks for the extensive testing!
Muting a rule just disables the actions from being scheduled, but the executor still runs. Writing the documents is "internal bookkeeping" that is performed in the executor and is independent of the user-defined actions. So yes, this is expected. The alert should still show up in the alerts tables even though notifications are muted.
Disabling a rule stop the check from being scheduled, which means the executor doesn't run. So this is expected as well. @mgiota does that make sense so far?
I think this is a quirk of the alerting framework. It seems to forget prior state when you save an edited alerts as if the alert was new. Since the executor of the "old version" doesn't have a chance to run it can't update the alert status. I expect this would also happen if an alert is deleted altogether. @dgieselaar has this been discussed before? How do we deal with indefinitely-open alerts like this? We would need to hook into the edit/delete lifecycle of the alert somehow. @mgiota to filter for that you could add a
|
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
💚 Backport successful
This backport PR will be merged automatically after passing CI. |
…-png-pdf-report-type * 'master' of github.com:elastic/kibana: (292 commits) bring back KQL autocomplete in timeline + fix last updated (elastic#105380) [Maps] Change TOC pop-up wording to reflect filter change, not search bar change (elastic#105163) Updating urls to upstream elastic repo (elastic#105250) [Maps] Move new vector layer wizard card down (elastic#104797) Exclude registering the cases feature if not enabled (elastic#105292) [Uptime] Alerts - Monitor status alert - check monitor status by monitor.timespan (elastic#104541) updated UI copy (elastic#105184) Log a warning when documents of unknown types are detected during migration (elastic#105213) [Logs UI] Register log threshold rule as lifecycle rule (elastic#104341) [Ingest pipelines] add network direction processor (elastic#103436) [Console] Autocomplete definitions (manual backport) (elastic#105086) [Security Solution] User can make Exceptions for Memory protection alerts (elastic#102196) [Lens] Formula: add validation for multiple field/metrics (elastic#104092) Removing async from file upload and data visualizer plugins start lifecycle (elastic#105197) Fix error when validating the form with non blocking validations (elastic#103629) [ML] Fix "View by" swim lane with applied filter and sorting by score (elastic#105217) Update dependency @elastic/charts to v32 (elastic#104625) [CTI] shortens large numbers on Dashboard Link Panel (elastic#105269) [Security Solution][Endpoint][Host Isolation] Fixes bug to remove excess host metadata status toasts on non user initiated errors (elastic#105331) [Cases] Fix pushing alerts count on every push to external service (elastic#105030) ... # Conflicts: # x-pack/plugins/reporting/common/types.ts
📝 Summary
This makes the log threshold alert lifecycle-aware.
closes #98379
closes #104857
🎨 Previews
🕵️ Review notes
createLifecycleRuleType
factory into acreateLifecycleExecutor
. The benefits are a reduced API surface and less tight coupling to the alerting framework. The old helper calls the new one internally but is left in place for now to avoid unnecessary changes to the APM plugin.params
are serialized into a log-threshold-rule-namespaced field in the doc. Discussions are ongoing whether the reason should be generated in the executor and indexed as-is, which would prevent internationalization. I stuck with how APM does it for now.