-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[ResponseOps] Move custom threshold rule params to the package #208686
[ResponseOps] Move custom threshold rule params to the package #208686
Conversation
/ci |
….com:guskovaue/kibana into MX-195191-move-custom-threshold-rule-package
Pinging @elastic/response-ops (Team:ResponseOps) |
src/platform/packages/shared/response-ops/rule_params/custom_threshold/v1.ts
Outdated
Show resolved
Hide resolved
Pinging @elastic/obs-ux-management-team (Team:obs-ux-management) |
src/platform/packages/shared/response-ops/rule_params/custom_threshold/v1.ts
Outdated
Show resolved
Hide resolved
src/platform/packages/shared/response-ops/rule_params/custom_threshold/v1.ts
Show resolved
Hide resolved
const comparators = Object.values({ ...COMPARATORS, ...LEGACY_COMPARATORS }); | ||
|
||
const allowedAggregators = Object.values(Aggregators); | ||
allowedAggregators.splice(Object.values(Aggregators).indexOf(Aggregators.COUNT), 1); |
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.
It is really strange for me to have this logic here. If we never use the element COUNT
of Aggregators
why not just do:
enum Aggregators { // or call it AllowedAggregators instead
// COUNT = 'count',
AVERAGE = 'avg',
SUM = 'sum',
MIN = 'min',
MAX = 'max',
CARDINALITY = 'cardinality',
RATE = 'rate',
P95 = 'p95',
P99 = 'p99',
LAST_VALUE = 'last_value',
}
Right now we are defining an enum
that is not used anywhere else and then in the only place we need it we always remove an element. Feels wrong.
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.
Agree. Made changes according comments here: 0652609
….com:guskovaue/kibana into MX-195191-move-custom-threshold-rule-package
import { dataViewSpecSchema } from '../common'; | ||
import { oneOfLiterals, validateKQLStringFilter, LEGACY_COMPARATORS } from '../common/utils'; | ||
|
||
const allowedAggregators = [ |
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 see this part has changed:
const allowedAggregators = Object.values(Aggregators);
allowedAggregators.splice(Object.values(Aggregators).indexOf(Aggregators.COUNT), 1);
Do we still have the Aggregators
types somewhere? I am trying to remember why we had two list and excluded one from the allowed list.
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.
So, it seems we have this type still in common (Aggregator), and we use it in a lot of places.
I like the idea of having this aggregator shared everywhere (i.e., moving the common aggregator type here), but then this will increase the scope of this PR. (There is no issue in using this package both in FE and server-side, right?)
@cnasikas thoughts?
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.
We decided not to change the way solutions use the types and the schemas due to a lack of domain knowledge. Also, some of the schemas are made with io-ts
and we need the schemas to be in kbn-config
. When the task is finished, we plan to inform you that you can use the package for types/schemas. It is up to the solutions to make the changes and use the types/schemas from the package if they want.
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.
Here is an idea that minimizes the number of changes, let me know what you think:
- Moving Aggregators enum to this package.
- Use it as before here:
const allowedAggregators = Object.values(Aggregators); allowedAggregators.splice(Object.values(Aggregators).indexOf(Aggregators.COUNT), 1);
- Instead of
aggType: schema.literal('count'),
, useto only rely on the enum.aggType: schema.literal(Aggregators.COUNT)
- Import Aggregators from here in the observability > common, so we don't need to change anything else.
Would that work?
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.
(There is no issue using this package on both the FE and server sides, right?)
I thought there was an issue using this in the FE since rule_params
uses the config-schema
which relies on some library(hapi
?) which is not usable on the front end. Maybe @cnasikas can confirm?
If so we could move this to a different rule_params_constants
package and then import it like you say.
As for the allowedAggregators
values + splice logic, I don't have a better alternative :(
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 checked again, and I don't see a usage other than related to the custom threshold rule. The AI assistant usage is also related to creating a custom threshold rule.
Is there another package related to rule types from which we can expose the Aggregators enum and use it in both places?
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 we have a centralized package where we expose the Aggregators enum and the rules params package uses it, we can accidentally introduce breaking changes if someone modifies the enum because the Rules APIs use it. Collocating it in the rule params avoids this issue. Also, who will own the centralized package Aggregators enum?
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 think the confusion comes from considering this enum separate from being a rule param. For us, there is no difference between this enum and the Aggregators that we use in the rule, and defining it as an enum helps us to keep the value in sync in all the usages.
Who will own the centralized package Aggregators enum?
This would be the same as this current package for exposing rule parameters, we just separate it to use it on FE as well due to the bundle limitation.
It would be good to have this improvement if we have a package that we can expose this enum, but I don't see it as a blocker, so I'll approve this PR.
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.
Thanks Maryam! I get your points. Let's talk about it offline.
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 created an issue for a rule_params_constants
package. #209547
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.
LGTM 👍
@elasticmachine merge upstream |
💚 Build Succeeded
Metrics [docs]
History
cc @guskovaue |
Starting backport for target branches: 9.0 https://github.com/elastic/kibana/actions/runs/13143813102 |
…ic#208686) Fixes: elastic#195191 Move log threshold rule type params to the new package. P.S.: I've moved function `validateKQLStringFilter` and test for it in my previous PR: elastic#205507 --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> (cherry picked from commit 07557b6)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…208686) (#209658) # Backport This will backport the following commits from `main` to `9.0`: - [[ResponseOps] Move custom threshold rule params to the package (#208686)](#208686) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Julia","email":"iuliia.guskova@elastic.co"},"sourceCommit":{"committedDate":"2025-02-04T20:01:05Z","message":"[ResponseOps] Move custom threshold rule params to the package (#208686)\n\nFixes: https://github.com/elastic/kibana/issues/195191\r\n\r\nMove log threshold rule type params to the new package.\r\n\r\nP.S.: I've moved function `validateKQLStringFilter` and test for it in\r\nmy previous PR: https://github.com/elastic/kibana/pull/205507\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>","sha":"07557b686c79c2af9dd3b2789c66efc1f6ca840d","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Alerting","release_note:skip","Team:ResponseOps","v9.0.0","backport:prev-minor","Team:obs-ux-management","v9.1.0"],"title":"[ResponseOps] Move custom threshold rule params to the package","number":208686,"url":"https://github.com/elastic/kibana/pull/208686","mergeCommit":{"message":"[ResponseOps] Move custom threshold rule params to the package (#208686)\n\nFixes: https://github.com/elastic/kibana/issues/195191\r\n\r\nMove log threshold rule type params to the new package.\r\n\r\nP.S.: I've moved function `validateKQLStringFilter` and test for it in\r\nmy previous PR: https://github.com/elastic/kibana/pull/205507\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>","sha":"07557b686c79c2af9dd3b2789c66efc1f6ca840d"}},"sourceBranch":"main","suggestedTargetBranches":["9.0"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/208686","number":208686,"mergeCommit":{"message":"[ResponseOps] Move custom threshold rule params to the package (#208686)\n\nFixes: https://github.com/elastic/kibana/issues/195191\r\n\r\nMove log threshold rule type params to the new package.\r\n\r\nP.S.: I've moved function `validateKQLStringFilter` and test for it in\r\nmy previous PR: https://github.com/elastic/kibana/pull/205507\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>","sha":"07557b686c79c2af9dd3b2789c66efc1f6ca840d"}}]}] BACKPORT--> Co-authored-by: Julia <iuliia.guskova@elastic.co>
…ic#208686) Fixes: elastic#195191 Move log threshold rule type params to the new package. P.S.: I've moved function `validateKQLStringFilter` and test for it in my previous PR: elastic#205507 --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Fixes: #195191
Move log threshold rule type params to the new package.
P.S.: I've moved function
validateKQLStringFilter
and test for it in my previous PR: #205507