-
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
[APM] Add transaction name filter in failed transaction rate rule type #155405
Merged
kpatticha
merged 9 commits into
elastic:main
from
kpatticha:152329-alert-transaction-name-error-rate
Apr 24, 2023
Merged
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3f0ed63
[APM] Add transaction name as field error rate rule type
kpatticha 1ccaa1d
Accept transaction name in error rate chart preview
kpatticha 2999e50
Fix warning
kpatticha 6084cfd
Make sure we don't query empty strings when runing rule executor
kpatticha a41a8f3
Fix type check
kpatticha f32f01b
Merge branch 'main' of github.com:elastic/kibana into 152329-alert-tr…
kpatticha 4458974
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine d8ebdd3
Merge branch 'main' into 152329-alert-transaction-name-error-rate
kibanamachine ebdef19
Merge branch 'main' into 152329-alert-transaction-name-error-rate
kibanamachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
.../public/components/alerting/rule_types/transaction_error_rate_rule_type/index.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { Story } from '@storybook/react'; | ||
import React, { ComponentType, useState } from 'react'; | ||
import { CoreStart } from '@kbn/core/public'; | ||
import { createKibanaReactContext } from '@kbn/kibana-react-plugin/public'; | ||
import { RuleParams, TransactionErrorRateRuleType } from '.'; | ||
import { AggregationType } from '../../../../../common/rules/apm_rule_types'; | ||
import { AlertMetadata } from '../../utils/helper'; | ||
import { ENVIRONMENT_ALL } from '../../../../../common/environment_filter_values'; | ||
|
||
const KibanaReactContext = createKibanaReactContext({ | ||
notifications: { toasts: { add: () => {} } }, | ||
} as unknown as Partial<CoreStart>); | ||
|
||
interface Args { | ||
ruleParams: RuleParams; | ||
metadata?: AlertMetadata; | ||
} | ||
|
||
export default { | ||
title: 'alerting/TransactionErrorRateRuleType', | ||
component: TransactionErrorRateRuleType, | ||
decorators: [ | ||
(StoryComponent: ComponentType) => { | ||
return ( | ||
<KibanaReactContext.Provider> | ||
<div style={{ width: 400 }}> | ||
<StoryComponent /> | ||
</div> | ||
</KibanaReactContext.Provider> | ||
); | ||
}, | ||
], | ||
}; | ||
|
||
export const CreatingInApmServiceOverview: Story<Args> = ({ | ||
ruleParams, | ||
metadata, | ||
}) => { | ||
const [params, setParams] = useState<RuleParams>(ruleParams); | ||
|
||
function setRuleParams(property: string, value: any) { | ||
setParams({ ...params, [property]: value }); | ||
} | ||
|
||
return ( | ||
<TransactionErrorRateRuleType | ||
ruleParams={params} | ||
metadata={metadata} | ||
setRuleParams={setRuleParams} | ||
setRuleProperty={() => {}} | ||
/> | ||
); | ||
}; | ||
|
||
CreatingInApmServiceOverview.args = { | ||
ruleParams: { | ||
aggregationType: AggregationType.Avg, | ||
environment: 'testEnvironment', | ||
serviceName: 'testServiceName', | ||
threshold: 1500, | ||
transactionType: 'testTransactionType', | ||
transactionName: 'GET /api/customer/:id', | ||
windowSize: 5, | ||
windowUnit: 'm', | ||
}, | ||
metadata: { | ||
environment: ENVIRONMENT_ALL.value, | ||
serviceName: undefined, | ||
}, | ||
}; | ||
|
||
export const CreatingInStackManagement: Story<Args> = ({ | ||
ruleParams, | ||
metadata, | ||
}) => { | ||
const [params, setParams] = useState<RuleParams>(ruleParams); | ||
|
||
function setRuleParams(property: string, value: any) { | ||
setParams({ ...params, [property]: value }); | ||
} | ||
|
||
return ( | ||
<TransactionErrorRateRuleType | ||
ruleParams={params} | ||
metadata={metadata} | ||
setRuleParams={setRuleParams} | ||
setRuleProperty={() => {}} | ||
/> | ||
); | ||
}; | ||
|
||
CreatingInStackManagement.args = { | ||
ruleParams: { | ||
aggregationType: AggregationType.Avg, | ||
environment: 'testEnvironment', | ||
threshold: 1500, | ||
windowSize: 5, | ||
windowUnit: 'm', | ||
}, | ||
metadata: undefined, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Was this mistakenly set to an empty string? What's the impact of this change?
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.
Yeah I'm also wondering what this means for eg updating existing rules?
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.
was added here: ad75d90 to reset the values when changing the service name but imo sending an empty string can lead to misleading results.
As for updating an existing rule, it will remove
transactionType
param from the list and it won't filter for thetransaction.type
However, the biggest impact seems to be in the rule executor. Existing rules may have filter fields with empty strings, and filtering emptry string would yield no results. To address this issue, we need to pass
queryEmptyString
as false when using termQuery for these fields.For example,
Fortunately, this issue has been fixed in v8.6, but there was a regression in my previous PR that caused the issue to resurface.
The tests we have in place were not sufficient to detect the regression. 😢
Next
I need to revert the change that removed the queryEmptyString parameter and ensure that empty strings are not filtered out
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, in most cases
undefined
is better than""
we just need to make sure that old rules with an empty string still works.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.
Can you fix that? :)
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.
Revert the change
I'll start working on the tests