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

[APM] Add transaction error rate alert #76933

Merged
merged 3 commits into from
Sep 17, 2020

Conversation

sorenlouv
Copy link
Member

@sorenlouv sorenlouv commented Sep 8, 2020

Closes #76367

  • Adds a new alert for Transaction Error Rate
  • Renames the existing alert error_rate to error_count to avoid confusion with transaction error rate
  • Made service name visible as read only for every alerting flyout
  • Made transaction type visible for every alerting flyout
  • Extracted "actionVariables" into a separate, shared file
  • extracted field types for servicename, environment and transaction type into separate, shared components
  • Made all alert parameters available to the alert description

It is now possible to write a message like the one below with the new alert parameters


Transaction type will be read-only if there's only a single value


Transaction type will be a dropdown if there's multiple values


Service name is now visible for all alerts even though it's not editable

@sorenlouv sorenlouv requested a review from a team as a code owner September 8, 2020 12:58
@botelastic botelastic bot added the Team:APM All issues that need APM UI Team support label Sep 8, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/apm-ui (Team:apm)

@@ -96,17 +109,22 @@ export function AlertIntegrations(props: Props) {
: []),
],
},

// transaction duration panel
Copy link
Member Author

@sorenlouv sorenlouv Sep 8, 2020

Choose a reason for hiding this comment

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

I can remove these comments again. Added them for my own sake but I can see how they are somewhat noisy/redundant.

}
)}
value={transactionType}
/>,
Copy link
Member Author

Choose a reason for hiding this comment

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

Transaction type used to be hidden. Now it's visible (read-only)

@sorenlouv sorenlouv force-pushed the add-transaction-error-rate-alert branch 2 times, most recently from ac6cade to 2eb1cd6 Compare September 8, 2020 20:50
@sorenlouv sorenlouv requested a review from a team as a code owner September 8, 2020 21:35
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.

Uptime code owner changes LGTM

Copy link
Member

@dgieselaar dgieselaar left a comment

Choose a reason for hiding this comment

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

If I try to create an anomaly alert I get an empty form:

image

If I try to create a transaction alert from the errors or metrics tab, type is empty and non-editable:

image

@sorenlouv sorenlouv force-pushed the add-transaction-error-rate-alert branch 2 times, most recently from 3843ec0 to 5336dbb Compare September 15, 2020 19:19
@elastic elastic deleted a comment from cla-checker-service bot Sep 15, 2020
@sorenlouv sorenlouv force-pushed the add-transaction-error-rate-alert branch from 67c4599 to 9caf99a Compare September 15, 2020 22:14
@elastic elastic deleted a comment from kibanamachine Sep 16, 2020
@sorenlouv
Copy link
Member Author

@dgieselaar All comments addressed

Comment on lines 86 to 89
const environmentFilter =
alertParams.environment === ENVIRONMENT_ALL.value
? []
: [{ term: { [SERVICE_ENVIRONMENT]: alertParams.environment } }];
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't we use something like getEnvironmentUiFilterES?

Copy link
Member Author

Choose a reason for hiding this comment

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

@sorenlouv sorenlouv force-pushed the add-transaction-error-rate-alert branch from 8dc074d to a9ce803 Compare September 17, 2020 09:08
Comment on lines +52 to +61
<ServiceField value={serviceName} />,
<EnvironmentField
currentValue={params.environment}
options={environmentOptions}
onChange={(e) => setAlertParams('environment', e.target.value)}
/>,
<IsAboveField
value={params.threshold}
unit={i18n.translate('xpack.apm.errorCountAlertTrigger.errors', {
defaultMessage: ' errors',
Copy link
Member Author

Choose a reason for hiding this comment

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

Extracting commonly-used field types into separate components. I was a little torn whether this improves readability by hiding boilerplate or hurts readability by adding an additional abstraction.
In the end I decided it was better.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not entirely sure if the space should be in the label.

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right. Was hoping you wouldn't notice 🙈
I'll fix it in a follow-up. For now I'll merge to avoid additional conflicts.


import { i18n } from '@kbn/i18n';

export const apmActionVariables = {
Copy link
Member Author

Choose a reason for hiding this comment

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

Extracted the action variables and their descriptions to avoid duplication and improve readability of alerts.

@@ -88,6 +73,7 @@ export function registerTransactionDurationAnomalyAlertType({

const anomalySearchParams = {
body: {
terminateAfter: 1,
Copy link
Member Author

Choose a reason for hiding this comment

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

@ogupte I added terminateAfter to improve perf of this alert since we only need a single document. Do you agree this is fine?

import { getEnvironmentLabel } from '../../../common/environment_filter_values';
import { PopoverExpression } from './ServiceAlertTrigger/PopoverExpression';

export function ServiceField({ value }: { value?: string }) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This file contains the commonly-used alerting fields. I intend for these fields to be almost 1:1 in their use across alerts. If they start to diverge we should abandon this approach (but I don't think that'll be the case)

Comment on lines +107 to +108
threshold: alertParams.threshold,
triggerValue: errorCount,
Copy link
Member Author

Choose a reason for hiding this comment

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

All threshold alerts now expose the threshold and the value that triggered the alert. They are consistently named threshold and triggerValue to make it easier to reuse templates between alerts.

Copy link
Member

@dgieselaar dgieselaar left a comment

Choose a reason for hiding this comment

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

nice improvements 👍🏻

Comment on lines +52 to +61
<ServiceField value={serviceName} />,
<EnvironmentField
currentValue={params.environment}
options={environmentOptions}
onChange={(e) => setAlertParams('environment', e.target.value)}
/>,
<IsAboveField
value={params.threshold}
unit={i18n.translate('xpack.apm.errorCountAlertTrigger.errors', {
defaultMessage: ' errors',
Copy link
Member

Choose a reason for hiding this comment

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

I'm not entirely sure if the space should be in the label.

import { SERVICE_ENVIRONMENT } from '../../../../common/elasticsearch_fieldnames';

export function getEnvironmentUiFilterES(environment?: string): ESFilter[] {
if (!environment) {
if (!environment || environment === ENVIRONMENT_ALL.value) {
Copy link
Member

Choose a reason for hiding this comment

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

What's the use case for having environment as an optional argument here?

Copy link
Member Author

Choose a reason for hiding this comment

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

getEnvironmentUiFilterES is called from places where environment is optional. Those callers would have to implement this themselves if it was required:

const envFilter = environment ? getEnvironmentUiFilterES(environment) : []

Copy link
Member Author

Choose a reason for hiding this comment

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

(is my guess - haven't checked)

Copy link
Member

Choose a reason for hiding this comment

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

I see. I guess what I'm arguing is that environment should never be undefined. It should always be ENVIRONMENT_ALL.value, ENVIRONMENT_NOT_DEFINED.value, or another non-empty string. But obviously that's a bigger and potentially painful change.

Copy link
Member Author

@sorenlouv sorenlouv Sep 17, 2020

Choose a reason for hiding this comment

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

Agree. I think right now the client will not send environment when "all" is selected. We should ofc always send a value regardless if "not defined", "all" or "" is selected.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

@kbn/optimizer bundle module count

id value diff baseline
apm 1264 +3 1261

async chunks size

id value diff baseline
apm 5.0MB +32.8KB 5.0MB

page load bundle size

id value diff baseline
apm 42.3KB +80.0B 42.3KB

distributable file count

id value diff baseline
default 45914 +5 45909

History

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

@sorenlouv sorenlouv merged commit fb62929 into elastic:master Sep 17, 2020
@sorenlouv sorenlouv deleted the add-transaction-error-rate-alert branch September 17, 2020 20:38
sorenlouv added a commit that referenced this pull request Sep 18, 2020
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
gmmorris added a commit to gmmorris/kibana that referenced this pull request Sep 22, 2020
* master: (92 commits)
  [ILM] Data tiers for 7.10 (elastic#76126)
  [ML] Transforms: Fixes styling of preview grid pagination in summary step (elastic#77789)
  [Drilldowns] Beta badge support. Mark URL Drilldown as Beta (elastic#75654)
  Re-enable session lifespan, idle timeout api integration tests and use unique names for the security test reports. (elastic#77746)
  [Alerting] renames code in alerting RBAC exemption to make it easier to maintain (elastic#77598)
  [Alerting & Actions] Overwrite SOs when updating instead of partially updating (elastic#73688)
  fixed react warning in Suspense in alert flyout (elastic#77777)
  [APM] Track usage of Gold+ features (elastic#77630)
  Visualize: Bad request when working with histogram aggregation (elastic#77684)
  remove legacy ES plugin (elastic#77703)
  [Lens] change name of custom query to filters (elastic#77725)
  skip flaky suite (elastic#76239)
  remove visual aspects of baseline job (elastic#77815)
  skip flaky suite (elastic#77835)
  Fixes typo in data recognizer text (elastic#77691)
  management/update trusted_apps jest snapshot
  [build] Use Elastic hosted UBI minimal base image (elastic#77776)
  [APM] Add transaction error rate alert (elastic#76933)
  [Security Solution] [Detections] Remove file validation on import route (elastic#77770)
  [Enterprise Search][tech debt] Add Kea logic paths for easier debugging/defaults (elastic#77698)
  ...
@cauemarcondes cauemarcondes self-assigned this Oct 12, 2020
@cauemarcondes
Copy link
Contributor

@sqren @formgeist should we validate if a user tries to create an alert with more than 100%?

Screenshot 2020-10-12 at 11 51 34

@sorenlouv
Copy link
Member Author

@cauemarcondes Good question. I think it's a nice-to-have. Is it easy to do?

@cauemarcondes
Copy link
Contributor

cauemarcondes commented Oct 12, 2020

@cauemarcondes Good question. I think it's a nice-to-have. Is it easy to do?

We can add isInvalid={value > 100} property to the field, but I don't think we have control over the Save button in the flyout, so there's no way to disable or enable it. I'd only show the field as red.

Maybe for 7.10 we should leave it like it is, and maybe change it for 7.11 if needed?

Screenshot 2020-10-12 at 12 45 43

@cauemarcondes
Copy link
Contributor

Tests ok:
Chrome ✅
FF ✅
Safari ✅

@cauemarcondes cauemarcondes added the apm:test-plan-done Pull request that was successfully tested during the test plan label Oct 12, 2020
@sorenlouv
Copy link
Member Author

Okay, then let's leave it for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apm:test-plan-done Pull request that was successfully tested during the test plan Team:APM All issues that need APM UI Team support v7.10.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[APM] Alerting: Add transaction error rate alert
6 participants