[8.x] [Synthetics] Enable KQL filter for TLS rules (#216973) (#218101)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Synthetics] Enable KQL filter for TLS rules
(#216973)](https://github.com/elastic/kibana/pull/216973)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Francesco
Fagnani","email":"fagnani.francesco@gmail.com"},"sourceCommit":{"committedDate":"2025-04-14T12:24:31Z","message":"[Synthetics]
Enable KQL filter for TLS rules (#216973)\n\nThis PR follows #215110 by
enabling the KQL filter for TLS alerting\nrules and closes
#214346.","sha":"89e385ec96591e4384bf70e268bbdc16fffe79b5","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:feature","Team:obs-ux-management","backport:version","v9.1.0","v8.19.0"],"title":"[Synthetics]
Enable KQL filter for TLS
rules","number":216973,"url":"https://github.com/elastic/kibana/pull/216973","mergeCommit":{"message":"[Synthetics]
Enable KQL filter for TLS rules (#216973)\n\nThis PR follows #215110 by
enabling the KQL filter for TLS alerting\nrules and closes
#214346.","sha":"89e385ec96591e4384bf70e268bbdc16fffe79b5"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/216973","number":216973,"mergeCommit":{"message":"[Synthetics]
Enable KQL filter for TLS rules (#216973)\n\nThis PR follows #215110 by
enabling the KQL filter for TLS alerting\nrules and closes
#214346.","sha":"89e385ec96591e4384bf70e268bbdc16fffe79b5"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Francesco Fagnani <fagnani.francesco@gmail.com>
This commit is contained in:
Kibana Machine 2025-04-14 16:17:51 +02:00 committed by GitHub
parent 1e2c9f09bf
commit 313e10da03
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 30 deletions

View file

@ -55,6 +55,7 @@ journey(`CustomTLSAlert`, async ({ page, params }) => {
step('Should open the create TLS rule flyout', async () => {
await page.getByTestId('syntheticsRefreshButtonButton').click();
await expect(page.getByTestId('syntheticsAlertsRulesButton')).toBeEnabled();
await page.getByTestId('syntheticsAlertsRulesButton').click();
await page.getByTestId('manageTlsRuleName').click();
await page.getByTestId('createNewTLSRule').click();
@ -62,13 +63,11 @@ journey(`CustomTLSAlert`, async ({ page, params }) => {
await expect(page.getByTestId('addRuleFlyoutTitle')).toBeVisible();
});
// This is needed for the intermediate release process -> https://docs.google.com/document/d/1mU5jlIfCKyXdDPtEzAz1xTpFXFCWxqdO5ldYRVO_hgM/edit?tab=t.0#heading=h.2b1v1tr0ep8m
// After the next serverless release the commit containing these changes can be reverted
step.skip('Should filter monitors using the KQL filter bar', async () => {
step('Should filter monitors using the KQL filter bar', async () => {
// Using the KQL filter to search for a monitor type of "tcp", 0 existing monitors should be found because the type of the test monitor is 'http'
await page.fill('[data-test-subj="queryInput"]', `monitor.type: "tcp" `);
await page.keyboard.press('Enter');
await expect(page.getByTestId('syntheticsRuleVizMonitorQueryIDsButton')).toHaveText(
await expect(page.getByTestId('syntheticsStatusRuleVizMonitorQueryIDsButton')).toHaveText(
'0 existing monitors'
);
@ -77,14 +76,12 @@ journey(`CustomTLSAlert`, async ({ page, params }) => {
await page.keyboard.press('Enter');
});
// This is needed for the intermediate release process -> https://docs.google.com/document/d/1mU5jlIfCKyXdDPtEzAz1xTpFXFCWxqdO5ldYRVO_hgM/edit?tab=t.0#heading=h.2b1v1tr0ep8m
// After the next serverless release the commit containing these changes can be reverted
step.skip('Should filter monitors by type', async () => {
step('Should filter monitors by type', async () => {
await page.getByRole('button', { name: 'Type All' }).click();
await page.getByTestId('comboBoxInput').click();
await page.getByRole('option', { name: 'http' }).click();
await page.getByTestId('ruleDefinition').getByRole('button', { name: 'Type http' }).click();
await expect(page.getByTestId('syntheticsRuleVizMonitorQueryIDsButton')).toHaveText(
await expect(page.getByTestId('syntheticsStatusRuleVizMonitorQueryIDsButton')).toHaveText(
'1 existing monitor'
);
});
@ -119,7 +116,9 @@ journey(`CustomTLSAlert`, async ({ page, params }) => {
await retry.tryForTime(5 * 1000, async () => {
await page.getByTestId('querySubmitButton').click();
await expect(page.getByText(tlsRuleName)).toBeVisible();
if (!(await page.getByText(tlsRuleName).isVisible())) {
throw new Error('Alert not found');
}
});
});
});

View file

@ -27,10 +27,7 @@ const tlsMonitorTypes = [MonitorTypeEnum.HTTP, MonitorTypeEnum.TCP];
export const TLSRuleComponent: React.FC<{
ruleParams: TLSRuleParamsProps['ruleParams'];
setRuleParams: TLSRuleParamsProps['setRuleParams'];
// This is needed for the intermediate release process -> https://docs.google.com/document/d/1mU5jlIfCKyXdDPtEzAz1xTpFXFCWxqdO5ldYRVO_hgM/edit?tab=t.0#heading=h.2b1v1tr0ep8m
// After the next serverless release the commit containing these changes can be reverted
showMonitorFilters?: boolean;
}> = ({ ruleParams, setRuleParams, showMonitorFilters = false }) => {
}> = ({ ruleParams, setRuleParams }) => {
const dispatch = useDispatch();
const { settings } = useSelector(selectDynamicSettings);
@ -59,23 +56,19 @@ export const TLSRuleComponent: React.FC<{
return (
<>
{showMonitorFilters ? (
<>
<AlertSearchBar
kqlQuery={ruleParams.kqlQuery ?? ''}
onChange={onFiltersChange}
filtersForSuggestions={filtersForSuggestions}
/>
<EuiSpacer size="m" />
<FieldFilters
ruleParams={ruleParams}
setRuleParams={setRuleParams}
filters={{ monitorTypes: tlsMonitorTypes }}
/>
<TLSRuleViz ruleParams={ruleParams} />
<EuiSpacer size="m" />
</>
) : null}
<AlertSearchBar
kqlQuery={ruleParams.kqlQuery ?? ''}
onChange={onFiltersChange}
filtersForSuggestions={filtersForSuggestions}
/>
<EuiSpacer size="m" />
<FieldFilters
ruleParams={ruleParams}
setRuleParams={setRuleParams}
filters={{ monitorTypes: tlsMonitorTypes }}
/>
<TLSRuleViz ruleParams={ruleParams} />
<EuiSpacer size="m" />
<AlertTlsCondition
ageThreshold={
ruleParams.certAgeThreshold ??