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

Alert creation and freeform selection #111883

Merged
merged 38 commits into from
Sep 29, 2021
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
ff386a3
create alert fixes
smith Sep 10, 2021
3b63130
add select component
smith Sep 10, 2021
b961e17
env sel
smith Sep 10, 2021
947b777
Merge remote-tracking branch 'upstream/master' into nls/create-alerts
smith Sep 13, 2021
487f73d
Merge remote-tracking branch 'upstream/master' into nls/create-alerts
smith Sep 14, 2021
1af6117
working env selection
smith Sep 14, 2021
11420c9
exclude e2e from server watch paths
smith Sep 14, 2021
5cbe080
e2e
smith Sep 14, 2021
d88e1ed
Merge remote-tracking branch 'upstream/master' into nls/create-alerts
smith Sep 15, 2021
085eb11
Record transaction duration alerts in microseconds
smith Sep 15, 2021
e020c0c
Merge remote-tracking branch 'upstream/master' into nls/create-alerts
smith Sep 16, 2021
0943d8c
some suggestion stuff
smith Sep 16, 2021
8af342a
Merge remote-tracking branch 'upstream/master' into nls/create-alerts
smith Sep 19, 2021
81e6ec8
rename fixes
smith Sep 20, 2021
87837c4
Merge remote-tracking branch 'upstream/master' into nls/create-alerts
smith Sep 21, 2021
6662aaa
prettier fix
smith Sep 21, 2021
40c491c
Merge remote-tracking branch 'upstream/master' into nls/create-alerts
smith Sep 21, 2021
eba1eaf
roll back change to get all environments
smith Sep 21, 2021
99c5560
environment suggestions
smith Sep 21, 2021
9ab39af
transaction type etc
smith Sep 21, 2021
376d9d3
remove old callout stuff
smith Sep 22, 2021
465756b
use new setting
smith Sep 23, 2021
f39cd75
Merge remote-tracking branch 'upstream/master' into nls/create-alerts
smith Sep 23, 2021
974c493
Merge remote-tracking branch 'upstream/master' into nls/create-alerts
smith Sep 23, 2021
2823f84
tests and initial trans type option
smith Sep 23, 2021
4b14a34
get all options working
smith Sep 23, 2021
6675c2b
Merge remote-tracking branch 'upstream/master' into nls/create-alerts
smith Sep 23, 2021
8039414
Merge remote-tracking branch 'upstream/master' into nls/create-alerts
smith Sep 27, 2021
86855ec
undo rename
smith Sep 27, 2021
7d08056
suggestion api updates
smith Sep 27, 2021
bb0ff80
Merge remote-tracking branch 'upstream/master' into nls/create-alerts
smith Sep 27, 2021
f4461d8
refactor
smith Sep 28, 2021
88a8789
Merge remote-tracking branch 'upstream/master' into nls/create-alerts
smith Sep 28, 2021
453711e
test fixes
smith Sep 28, 2021
b025b30
Merge remote-tracking branch 'upstream/master' into nls/create-alerts
smith Sep 28, 2021
b9e6659
type fix
smith Sep 28, 2021
8831793
Merge remote-tracking branch 'upstream/master' into nls/create-alerts
smith Sep 28, 2021
959fc25
Merge remote-tracking branch 'upstream/master' into nls/create-alerts
smith Sep 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -408,12 +408,12 @@ export const stackManagementSchema: MakeSchemaFrom<UsageStats> = {
type: 'text',
_meta: { description: 'Non-default value of setting.' },
},
'apm:enableSignificantTerms': {
'observability:enableInspectEsQueries': {
type: 'boolean',
_meta: { description: 'Non-default value of setting.' },
},
'observability:enableInspectEsQueries': {
type: 'boolean',
'observability:maxSuggestions': {
type: 'integer',
_meta: { description: 'Non-default value of setting.' },
},
'banners:placement': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export interface UsageStats {
'discover:showMultiFields': boolean;
'discover:maxDocFieldsDisplayed': number;
'securitySolution:rulesTableRefresh': string;
'apm:enableSignificantTerms': boolean;
'observability:enableInspectEsQueries': boolean;
'observability:maxSuggestions': number;
'visualize:enableLabs': boolean;
'visualization:heatmap:maxBuckets': number;
'visualization:colorMapping': string;
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/telemetry/schema/oss_plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -7629,14 +7629,14 @@
"description": "Non-default value of setting."
}
},
"apm:enableSignificantTerms": {
"observability:enableInspectEsQueries": {
"type": "boolean",
"_meta": {
"description": "Non-default value of setting."
}
},
"observability:enableInspectEsQueries": {
"type": "boolean",
"observability:maxSuggestions": {
"type": "integer",
"_meta": {
"description": "Non-default value of setting."
}
Expand Down
14 changes: 0 additions & 14 deletions x-pack/plugins/apm/dev_docs/feature_flags.md

This file was deleted.

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');
});
});
});
});
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,
};
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);
Copy link
Member

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?

Copy link
Contributor Author

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.


describe('ErrorCountAlertTrigger', () => {
it('renders', () => {
expect(() => render(<CreatingInApmFromService />)).not.toThrowError();
});
});

This file was deleted.

Loading