Skip to content

Commit

Permalink
[APM] Integrate Alert Search bar in alert tab (#149610)
Browse files Browse the repository at this point in the history
## Summary

Closes: #146290

- Integrate Alert search bar
- Delete alerts status filters as it comes for free with the search bar
- Respect time range when fetching alert counts on service inventory and
service overview page
- as the search bar now supports time ranges, it's required to display
consistent data.

### Before 


![image](https://user-images.githubusercontent.com/3369346/214894397-6850274f-f701-481a-a12c-688c144f4c32.png)



### After


https://user-images.githubusercontent.com/3369346/214894788-5fcd42e2-b48f-434f-b38d-18579bfc280e.mov


TODO
- [x]
[getServiceAlerts](https://github.com/elastic/kibana/pull/149610/files#diff-82ef341af674bd7f203551b4d75b73d221a49e6ae4169e0c396e96abb04902bcR59-R67
) query doesn't include environment while the table respects that
filter. Check what's the correct way.

---------

Co-authored-by: kibanamachine <[email protected]>
  • Loading branch information
kpatticha and kibanamachine authored Jan 27, 2023
1 parent 6cc9855 commit 5476c93
Show file tree
Hide file tree
Showing 12 changed files with 173 additions and 307 deletions.
19 changes: 16 additions & 3 deletions x-pack/plugins/apm/common/environment_filter_values.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import { i18n } from '@kbn/i18n';
import { escapeKuery } from '@kbn/es-query';
import { SERVICE_ENVIRONMENT } from './es_fields/apm';
import { Environment } from './environment_rt';

Expand Down Expand Up @@ -43,18 +44,30 @@ export const ENVIRONMENT_NOT_DEFINED = {
label: getEnvironmentLabel(ENVIRONMENT_NOT_DEFINED_VALUE),
};

export function getEnvironmentEsField(environment: string) {
if (
function isEnvironmentDefined(environment: string) {
return (
!environment ||
environment === ENVIRONMENT_NOT_DEFINED_VALUE ||
environment === ENVIRONMENT_ALL_VALUE
) {
);
}

export function getEnvironmentEsField(environment: string) {
if (isEnvironmentDefined(environment)) {
return {};
}

return { [SERVICE_ENVIRONMENT]: environment };
}

export function getEnvironmentKuery(environment: string) {
if (isEnvironmentDefined(environment)) {
return null;
}

return `${[SERVICE_ENVIRONMENT]}: ${escapeKuery(environment)} `;
}

// returns the environment url param that should be used
// based on the requested environment. If the requested
// environment is different from the URL parameter, we'll
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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 url from 'url';
import { synthtrace } from '../../../../synthtrace';
import { opbeans } from '../../../fixtures/synthtrace/opbeans';

const start = '2021-10-10T00:00:00.000Z';
const end = '2021-10-10T00:15:00.000Z';

const serviceOverviewHref = url.format({
pathname: '/app/apm/services/opbeans-java/alerts',
query: { rangeFrom: start, rangeTo: end },
});

describe('Errors table', () => {
before(() => {
synthtrace.index(
opbeans({
from: new Date(start).getTime(),
to: new Date(end).getTime(),
})
);
});

after(() => {
synthtrace.clean();
});

beforeEach(() => {
cy.loginAsViewerUser();
});

it('Alerts table with the search bar is populated', () => {
cy.visitKibana(serviceOverviewHref);
cy.contains('opbeans-java');
cy.contains('All');
cy.contains('Active');
cy.contains('Recovered');
cy.getByTestSubj('globalQueryBar').should('exist');
});
});

This file was deleted.

This file was deleted.

Loading

0 comments on commit 5476c93

Please sign in to comment.