-
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
Alert creation and freeform selection #111883
Merged
Merged
Changes from 37 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
ff386a3
create alert fixes
smith 3b63130
add select component
smith b961e17
env sel
smith 947b777
Merge remote-tracking branch 'upstream/master' into nls/create-alerts
smith 487f73d
Merge remote-tracking branch 'upstream/master' into nls/create-alerts
smith 1af6117
working env selection
smith 11420c9
exclude e2e from server watch paths
smith 5cbe080
e2e
smith d88e1ed
Merge remote-tracking branch 'upstream/master' into nls/create-alerts
smith 085eb11
Record transaction duration alerts in microseconds
smith e020c0c
Merge remote-tracking branch 'upstream/master' into nls/create-alerts
smith 0943d8c
some suggestion stuff
smith 8af342a
Merge remote-tracking branch 'upstream/master' into nls/create-alerts
smith 81e6ec8
rename fixes
smith 87837c4
Merge remote-tracking branch 'upstream/master' into nls/create-alerts
smith 6662aaa
prettier fix
smith 40c491c
Merge remote-tracking branch 'upstream/master' into nls/create-alerts
smith eba1eaf
roll back change to get all environments
smith 99c5560
environment suggestions
smith 9ab39af
transaction type etc
smith 376d9d3
remove old callout stuff
smith 465756b
use new setting
smith f39cd75
Merge remote-tracking branch 'upstream/master' into nls/create-alerts
smith 974c493
Merge remote-tracking branch 'upstream/master' into nls/create-alerts
smith 2823f84
tests and initial trans type option
smith 4b14a34
get all options working
smith 6675c2b
Merge remote-tracking branch 'upstream/master' into nls/create-alerts
smith 8039414
Merge remote-tracking branch 'upstream/master' into nls/create-alerts
smith 86855ec
undo rename
smith 7d08056
suggestion api updates
smith bb0ff80
Merge remote-tracking branch 'upstream/master' into nls/create-alerts
smith f4461d8
refactor
smith 88a8789
Merge remote-tracking branch 'upstream/master' into nls/create-alerts
smith 453711e
test fixes
smith b025b30
Merge remote-tracking branch 'upstream/master' into nls/create-alerts
smith b9e6659
type fix
smith 8831793
Merge remote-tracking branch 'upstream/master' into nls/create-alerts
smith 959fc25
Merge remote-tracking branch 'upstream/master' into nls/create-alerts
smith 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
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 was deleted.
Oops, something went wrong.
108 changes: 108 additions & 0 deletions
108
x-pack/plugins/apm/ftr_e2e/cypress/integration/power_user/rules/error_count.spec.ts
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. | ||
*/ | ||
|
||
describe('Rules', () => { | ||
describe('Error count', () => { | ||
const ruleName = 'Error count threshold'; | ||
const comboBoxInputSelector = | ||
'.euiPopover__panel-isOpen [data-test-subj=comboBoxSearchInput]'; | ||
const confirmModalButtonSelector = | ||
'.euiModal button[data-test-subj=confirmModalConfirmButton]'; | ||
const deleteButtonSelector = | ||
'[data-test-subj=deleteActionHoverButton]:first'; | ||
const editButtonSelector = '[data-test-subj=editActionHoverButton]:first'; | ||
|
||
describe('when created from APM', () => { | ||
describe('when created from Service Inventory', () => { | ||
before(() => { | ||
cy.loginAsPowerUser(); | ||
}); | ||
|
||
it('creates and updates a rule', () => { | ||
// Create a rule in APM | ||
cy.visit('/app/apm/services'); | ||
cy.contains('Alerts and rules').click(); | ||
cy.contains('Error count').click(); | ||
cy.contains('Create threshold rule').click(); | ||
|
||
// Change the environment to "testing" | ||
cy.contains('Environment All').click(); | ||
cy.get(comboBoxInputSelector).type('testing{enter}'); | ||
|
||
// Save, with no actions | ||
cy.contains('button:not(:disabled)', 'Save').click(); | ||
cy.get(confirmModalButtonSelector).click(); | ||
|
||
cy.contains(`Created rule "${ruleName}`); | ||
|
||
// Go to Stack Management | ||
cy.contains('Alerts and rules').click(); | ||
cy.contains('Manage rules').click(); | ||
|
||
// Edit the rule, changing the environment to "All" | ||
cy.get(editButtonSelector).click(); | ||
cy.contains('Environment testing').click(); | ||
cy.get(comboBoxInputSelector).type('All{enter}'); | ||
cy.contains('button:not(:disabled)', 'Save').click(); | ||
|
||
cy.contains(`Updated '${ruleName}'`); | ||
|
||
// Wait for the table to be ready for next edit click | ||
cy.get('.euiBasicTable').not('.euiBasicTable-loading'); | ||
|
||
// Ensure the rule now shows "All" for the environment | ||
cy.get(editButtonSelector).click(); | ||
cy.contains('Environment All'); | ||
cy.contains('button', 'Cancel').click(); | ||
|
||
// Delete the rule | ||
cy.get(deleteButtonSelector).click(); | ||
cy.get(confirmModalButtonSelector).click(); | ||
|
||
// Ensure the table is empty | ||
cy.contains('Create your first rule'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('when created from Stack management', () => { | ||
before(() => { | ||
cy.loginAsPowerUser(); | ||
}); | ||
|
||
it('creates a rule', () => { | ||
// Go to stack management | ||
cy.visit('/app/management/insightsAndAlerting/triggersActions/rules'); | ||
|
||
// Create a rule | ||
cy.contains('button', 'Create rule').click(); | ||
cy.get('[name=name]').type(ruleName); | ||
cy.contains('.euiFlyout button', ruleName).click(); | ||
|
||
// Change the environment to "testing" | ||
cy.contains('Environment All').click(); | ||
cy.get(comboBoxInputSelector).type('testing{enter}'); | ||
|
||
// Save, with no actions | ||
cy.contains('button:not(:disabled)', 'Save').click(); | ||
cy.get(confirmModalButtonSelector).click(); | ||
|
||
cy.contains(`Created rule "${ruleName}`); | ||
|
||
// Wait for the table to be ready for next delete click | ||
cy.get('.euiBasicTable').not('.euiBasicTable-loading'); | ||
|
||
// Delete the rule | ||
cy.get(deleteButtonSelector).click(); | ||
cy.get(confirmModalButtonSelector).click(); | ||
|
||
// Ensure the table is empty | ||
cy.contains('Create your first rule'); | ||
}); | ||
}); | ||
}); | ||
}); |
152 changes: 152 additions & 0 deletions
152
...ublic/components/alerting/error_count_alert_trigger/error_count_alert_trigger.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,152 @@ | ||
/* | ||
* 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 { Meta, Story } from '@storybook/react'; | ||
import React, { useState } from 'react'; | ||
import { AlertParams, ErrorCountAlertTrigger } from '.'; | ||
import { CoreStart } from '../../../../../../../src/core/public'; | ||
import { createKibanaReactContext } from '../../../../../../../src/plugins/kibana_react/public'; | ||
import { ENVIRONMENT_ALL } from '../../../../common/environment_filter_values'; | ||
import { AlertMetadata } from '../helper'; | ||
|
||
const KibanaReactContext = createKibanaReactContext({ | ||
notifications: { toasts: { add: () => {} } }, | ||
} as unknown as Partial<CoreStart>); | ||
|
||
interface Args { | ||
alertParams: AlertParams; | ||
metadata?: AlertMetadata; | ||
} | ||
|
||
const stories: Meta<{}> = { | ||
title: 'alerting/ErrorCountAlertTrigger', | ||
component: ErrorCountAlertTrigger, | ||
decorators: [ | ||
(StoryComponent) => { | ||
return ( | ||
<KibanaReactContext.Provider> | ||
<div style={{ width: 400 }}> | ||
<StoryComponent /> | ||
</div> | ||
</KibanaReactContext.Provider> | ||
); | ||
}, | ||
], | ||
}; | ||
export default stories; | ||
|
||
export const CreatingInApmFromInventory: Story<Args> = ({ | ||
alertParams, | ||
metadata, | ||
}) => { | ||
const [params, setParams] = useState<AlertParams>(alertParams); | ||
|
||
function setAlertParams(property: string, value: any) { | ||
setParams({ ...params, [property]: value }); | ||
} | ||
|
||
return ( | ||
<ErrorCountAlertTrigger | ||
alertParams={params} | ||
metadata={metadata} | ||
setAlertParams={setAlertParams} | ||
setAlertProperty={() => {}} | ||
/> | ||
); | ||
}; | ||
CreatingInApmFromInventory.args = { | ||
alertParams: {}, | ||
metadata: { | ||
end: '2021-09-10T14:14:04.789Z', | ||
environment: ENVIRONMENT_ALL.value, | ||
serviceName: undefined, | ||
start: '2021-09-10T13:59:00.000Z', | ||
}, | ||
}; | ||
|
||
export const CreatingInApmFromService: Story<Args> = ({ | ||
alertParams, | ||
metadata, | ||
}) => { | ||
const [params, setParams] = useState<AlertParams>(alertParams); | ||
|
||
function setAlertParams(property: string, value: any) { | ||
setParams({ ...params, [property]: value }); | ||
} | ||
|
||
return ( | ||
<ErrorCountAlertTrigger | ||
alertParams={params} | ||
metadata={metadata} | ||
setAlertParams={setAlertParams} | ||
setAlertProperty={() => {}} | ||
/> | ||
); | ||
}; | ||
CreatingInApmFromService.args = { | ||
alertParams: {}, | ||
metadata: { | ||
end: '2021-09-10T14:14:04.789Z', | ||
environment: 'testEnvironment', | ||
serviceName: 'testServiceName', | ||
start: '2021-09-10T13:59:00.000Z', | ||
}, | ||
}; | ||
|
||
export const EditingInStackManagement: Story<Args> = ({ | ||
alertParams, | ||
metadata, | ||
}) => { | ||
const [params, setParams] = useState<AlertParams>(alertParams); | ||
|
||
function setAlertParams(property: string, value: any) { | ||
setParams({ ...params, [property]: value }); | ||
} | ||
|
||
return ( | ||
<ErrorCountAlertTrigger | ||
alertParams={params} | ||
metadata={metadata} | ||
setAlertParams={setAlertParams} | ||
setAlertProperty={() => {}} | ||
/> | ||
); | ||
}; | ||
EditingInStackManagement.args = { | ||
alertParams: { | ||
environment: 'testEnvironment', | ||
serviceName: 'testServiceName', | ||
threshold: 25, | ||
windowSize: 1, | ||
windowUnit: 'm', | ||
}, | ||
metadata: undefined, | ||
}; | ||
|
||
export const CreatingInStackManagement: Story<Args> = ({ | ||
alertParams, | ||
metadata, | ||
}) => { | ||
const [params, setParams] = useState<AlertParams>(alertParams); | ||
|
||
function setAlertParams(property: string, value: any) { | ||
setParams({ ...params, [property]: value }); | ||
} | ||
|
||
return ( | ||
<ErrorCountAlertTrigger | ||
alertParams={params} | ||
metadata={metadata} | ||
setAlertParams={setAlertParams} | ||
setAlertProperty={() => {}} | ||
/> | ||
); | ||
}; | ||
CreatingInStackManagement.args = { | ||
alertParams: {}, | ||
metadata: undefined, | ||
}; |
19 changes: 19 additions & 0 deletions
19
...m/public/components/alerting/error_count_alert_trigger/error_count_alert_trigger.test.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,19 @@ | ||
/* | ||
* 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 { render } from '@testing-library/react'; | ||
import React from 'react'; | ||
import * as stories from './error_count_alert_trigger.stories'; | ||
import { composeStories } from '@storybook/testing-react'; | ||
|
||
const { CreatingInApmFromService } = composeStories(stories); | ||
|
||
describe('ErrorCountAlertTrigger', () => { | ||
it('renders', () => { | ||
expect(() => render(<CreatingInApmFromService />)).not.toThrowError(); | ||
}); | ||
}); |
51 changes: 0 additions & 51 deletions
51
x-pack/plugins/apm/public/components/alerting/error_count_alert_trigger/index.stories.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.
Yay! Great to see storybook and testing-library playing well together. What's your impression of this so far?
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's pretty great. Centralizes most of the boilerplate and makes injecting data easy.