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

chore(slo): Improve active alerts badge #155290

Merged
merged 1 commit into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -8,17 +8,18 @@
import { EuiBadge, EuiFlexItem } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React from 'react';
import { SLOWithSummaryResponse } from '@kbn/slo-schema';

import { paths } from '../../../config/paths';
import { useKibana } from '../../../utils/kibana_react';

import { ActiveAlerts } from '../../../hooks/slo/use_fetch_active_alerts';
import { toAlertsPageQueryFilter } from '../../../pages/slos/helpers/alerts_page_query_filter';

export interface Props {
activeAlerts?: ActiveAlerts;
slo: SLOWithSummaryResponse;
}

export function SloActiveAlertsBadge({ activeAlerts }: Props) {
export function SloActiveAlertsBadge({ slo, activeAlerts }: Props) {
const {
application: { navigateToUrl },
http: { basePath },
Expand All @@ -27,9 +28,9 @@ export function SloActiveAlertsBadge({ activeAlerts }: Props) {
const handleActiveAlertsClick = () => {
if (activeAlerts) {
navigateToUrl(
`${basePath.prepend(paths.observability.alerts)}?_a=${toAlertsPageQueryFilter(
activeAlerts
)}`
`${basePath.prepend(paths.observability.alerts)}?_a=(kuery:'slo.id:"${
slo.id
}"',rangeFrom:now-15m,rangeTo:now,status:active)`
);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ export function useFetchActiveAlerts({ sloIds = [] }: Params): UseFetchActiveAle
query: {
bool: {
filter: [
{
range: {
'@timestamp': {
gte: 'now-15m/m',
},
},
},
{
term: {
'kibana.alert.rule.rule_type_id': 'slo.rules.burnRate',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function HeaderTitle(props: Props) {
<EuiFlexItem grow={false}>{slo.name}</EuiFlexItem>
<EuiFlexGroup direction="row" gutterSize="s" alignItems="center" responsive={false}>
<SloStatusBadge slo={slo} />
<SloActiveAlertsBadge activeAlerts={activeAlerts[slo.id]} />
<SloActiveAlertsBadge slo={slo} activeAlerts={activeAlerts[slo.id]} />
</EuiFlexGroup>
</EuiFlexGroup>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function SloBadges({ activeAlerts, rules, slo, onClickRuleBadge }: Props)
<SloStatusBadge slo={slo} />
<SloIndicatorTypeBadge slo={slo} />
<SloTimeWindowBadge slo={slo} />
<SloActiveAlertsBadge activeAlerts={activeAlerts} />
<SloActiveAlertsBadge slo={slo} activeAlerts={activeAlerts} />
<SloRulesBadge rules={rules} onClick={onClickRuleBadge} />
</EuiFlexGroup>
);
Expand Down

This file was deleted.

This file was deleted.