-
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
Revisit custom threshold types in public folder #170306
Revisit custom threshold types in public folder #170306
Conversation
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
x-pack/plugins/observability/server/lib/rules/custom_threshold/custom_threshold_executor.ts
Show resolved
Hide resolved
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.
@maryam-saeidi, when visiting the rule details it shows an error about not enabling to get the execution history.
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.
@@ -5,16 +5,13 @@ | |||
* 2.0. | |||
*/ | |||
|
|||
export const SNAPSHOT_CUSTOM_AGGREGATIONS = ['avg', 'max', 'min', 'rate'] as const; | |||
export const METRIC_EXPLORER_AGGREGATIONS = [ |
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.
To be deleted it's not used anymore.
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.
Actually, this is still used in x-pack/plugins/observability/server/lib/rules/custom_threshold/register_custom_threshold_rule_type.ts
@@ -22,7 +23,7 @@ export const scenario2 = { | |||
params: { | |||
criteria: [ | |||
{ | |||
aggType: Aggregators.CUSTOM, | |||
aggType: CUSTOM_AGGREGATOR, |
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.
Same: I think we should keep referring to the custom
from Aggregators
to keep everything on track when an updates occurs. Can you explain the benefits of not using the value fromAggregators
?
I will not repeate the same comment for the other files :D
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 changed it to CUSTOM_AGGREGATOR
because it is the only acceptable value at this level and does not belong to Aggregators
anymore. There were a lot of type duplications to handle this scenario, and by splitting them, we don't need to exclude custom
from Aggregators
to be used in the rule.
I am considering creating a ticket to remove CUSTOM_AGGREGATOR
everywhere if it does not have a backward compatibility issue.
@@ -14,7 +14,7 @@ import { InfraWaffleMapDataFormat } from './types'; | |||
|
|||
export const FORMATTERS = { | |||
number: formatNumber, | |||
// Because the implimentation for formatting large numbers is the same as formatting | |||
// Because the implementation for formatting large numbers is the same as formatting |
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.
👍
* 2.0. | ||
*/ | ||
|
||
import * as rt from 'io-ts'; |
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.
👏🏻 DELETEING
* | ||
* This utility function can be used to turn a TypeScript enum into a io-ts codec. | ||
*/ | ||
export function fromEnum<EnumType extends string>( |
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.
What does this function do?
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 for turning a Typescript enum into an io-ts validation. I used it for the 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.
there is already some nice utils exposed via perhaps worth reusing that or move that into packages/kbn-io-ts-utils
import { enumeration } from '@kbn/securitysolution-io-ts-types';
const { groupBy, filterQuery, metrics } = metricThresholdPrefill; | ||
|
||
return <AlertFlyout options={{ groupBy, filterQuery, metrics }} visible setVisible={onClose} />; | ||
return <AlertFlyout visible setVisible={onClose} />; |
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 don't need to send options={{ groupBy, filterQuery, metrics }}
?
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 related to preFill logic; I removed it because it did not match the new custom threshold structure and created a ticket to add this logic correctly (#170295)
@fkanout I tried the Stateful rule details page and didn't face the issue you shared. Can you please check which API fails and if there are any error logs in your server? Is it related to changes in 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.
LGTM !!
Tested creating threshold rule, editing, charts, group by and rule details page. !!
@maryam-saeidi I think using a different unit for percentage metrics is confusing for user and we need to handle different scenarios when switching between percentage and non-percentage metrics. Also, how do we handle a scenario when all metrics in a condition are percentage. Switching from
|
@benakansara For now, I only handled the scenario that there is only one percentage metric, which is similar to what we had in the Metric threshold. It should be easy to do the same when all the metrics are percentages if we decide to do so. I'll create an issue to get @maciejforcone 's opinion on this case as well. This improvement helps to see the value of percentage fields accordingly instead of setting 0.1 as the threshold for percentage fields, but I agree that the current solution is not perfect either. Regarding the first issue, I didn't find an ideal solution; one possible option is not to have a default value for the threshold similar to the Metric threshold. Let's discuss this with @maciejforcone as well. Issue: #171121 |
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
Page load bundle
Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
Part of #159340
Closes #169364
Summary
This PR:
In this PR, I removed the logic about prefilling custom threshold rule params as it was originally for other rule types (not custom equation) and to be used in the Metric threshold rule and the code related to this logic was super confusing, and I wasn't even sure if it works as expected since we haven't used this logic anywhere. I created a ticket to bring back this feature properly later, specifically for the custom equation, and integrate it in one of the apps, such as Infra. We also need to be able to preFill data view information (both adHoc and persisted data view)
metricThreshold
tocustomThreshold
metricExplorer
toexpression
Also, the fields that end with
pct
now have the%
after the related value: (The reason message was fixed in another PR)🧪 How to test