Skip to content

Commit

Permalink
[9.0] Add location, fix name badge links for Synthetics SLOs (#210695) (
Browse files Browse the repository at this point in the history
#210930)

# Backport

This will backport the following commits from `main` to `9.0`:
- [Add location, fix name badge links for Synthetics SLOs
(#210695)](#210695)

<!--- Backport version: 9.4.3 -->

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

<!--BACKPORT [{"author":{"name":"Bailey
Cash","email":"bailey.cash@elastic.co"},"sourceCommit":{"committedDate":"2025-02-12T20:08:13Z","message":"Add
location, fix name badge links for Synthetics SLOs (#210695)\n\n##
Summary\r\n\r\n- Implements #178138 \r\n- Fixes a bug where clicking on
the existing link to the monitor via the\r\nname badge led failed to
load any data.\r\n\r\n## Release Notes\r\n- Fixes a bug where clicking
on the name badge for a synthetics monitor\r\non an SLO details page
would lead to a page that failed to load monitor\r\ndetails.\r\n- Adds a
working link to the location badge on synthetics SLOs that will\r\nroute
the user to the monitors page with a filter applied that matches\r\nthe
location of the origin SLO.\r\n\r\n![Screenshot 2025-02-11 at 3
31\r\n15 PM](https://github.com/user-attachments/assets/1df39069-fc42-4c33-a7e5-8395b2730f43)\r\n![Screenshot
2025-02-11 at 3
31\r\n34 PM](https://github.com/user-attachments/assets/f1b3180f-eb9c-4f3b-9ff6-66bd4d1f8d5b)","sha":"4d3cf33ffd6d561cb73c1bccd53c643f3846cc1e","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:enhancement","release_note:fix","v9.0.0","backport:prev-minor","Team:obs-ux-management","v9.1.0"],"title":"Add
location, fix name badge links for Synthetics
SLOs","number":210695,"url":"https://github.com/elastic/kibana/pull/210695","mergeCommit":{"message":"Add
location, fix name badge links for Synthetics SLOs (#210695)\n\n##
Summary\r\n\r\n- Implements #178138 \r\n- Fixes a bug where clicking on
the existing link to the monitor via the\r\nname badge led failed to
load any data.\r\n\r\n## Release Notes\r\n- Fixes a bug where clicking
on the name badge for a synthetics monitor\r\non an SLO details page
would lead to a page that failed to load monitor\r\ndetails.\r\n- Adds a
working link to the location badge on synthetics SLOs that will\r\nroute
the user to the monitors page with a filter applied that matches\r\nthe
location of the origin SLO.\r\n\r\n![Screenshot 2025-02-11 at 3
31\r\n15 PM](https://github.com/user-attachments/assets/1df39069-fc42-4c33-a7e5-8395b2730f43)\r\n![Screenshot
2025-02-11 at 3
31\r\n34 PM](https://github.com/user-attachments/assets/f1b3180f-eb9c-4f3b-9ff6-66bd4d1f8d5b)","sha":"4d3cf33ffd6d561cb73c1bccd53c643f3846cc1e"}},"sourceBranch":"main","suggestedTargetBranches":["9.0"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/210695","number":210695,"mergeCommit":{"message":"Add
location, fix name badge links for Synthetics SLOs (#210695)\n\n##
Summary\r\n\r\n- Implements #178138 \r\n- Fixes a bug where clicking on
the existing link to the monitor via the\r\nname badge led failed to
load any data.\r\n\r\n## Release Notes\r\n- Fixes a bug where clicking
on the name badge for a synthetics monitor\r\non an SLO details page
would lead to a page that failed to load monitor\r\ndetails.\r\n- Adds a
working link to the location badge on synthetics SLOs that will\r\nroute
the user to the monitors page with a filter applied that matches\r\nthe
location of the origin SLO.\r\n\r\n![Screenshot 2025-02-11 at 3
31\r\n15 PM](https://github.com/user-attachments/assets/1df39069-fc42-4c33-a7e5-8395b2730f43)\r\n![Screenshot
2025-02-11 at 3
31\r\n34 PM](https://github.com/user-attachments/assets/f1b3180f-eb9c-4f3b-9ff6-66bd4d1f8d5b)","sha":"4d3cf33ffd6d561cb73c1bccd53c643f3846cc1e"}}]}]
BACKPORT-->

Co-authored-by: Bailey Cash <bailey.cash@elastic.co>
Co-authored-by: Shahzad <shahzad31comp@gmail.com>
  • Loading branch information
3 people authored Feb 18, 2025
1 parent 75e54da commit 852a008
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ export const observabilityFeatureId = 'observability';
// by other plugins as well, so defined here to prevent cross-references.
export { uptimeOverviewLocatorID } from '@kbn/deeplinks-observability';
export const syntheticsMonitorDetailLocatorID = 'SYNTHETICS_MONITOR_DETAIL_LOCATOR';
export const syntheticsMonitorLocationQueryLocatorID =
'SYNTHETICS_MONITOR_GROUP_BY_LOCATION_LOCATOR';
export const syntheticsEditMonitorLocatorID = 'SYNTHETICS_EDIT_MONITOR_LOCATOR';
export const syntheticsSettingsLocatorID = 'SYNTHETICS_SETTINGS';
export const alertsLocatorID = 'ALERTS_LOCATOR';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import { EuiBadge, EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { syntheticsAvailabilityIndicatorSchema, SLOWithSummaryResponse } from '@kbn/slo-schema';
import React from 'react';
import { syntheticsMonitorDetailLocatorID } from '@kbn/observability-plugin/common';
import {
syntheticsMonitorDetailLocatorID,
syntheticsMonitorLocationQueryLocatorID,
} from '@kbn/observability-plugin/common';
import { useKibana } from '../../../../hooks/use_kibana';
import { OverviewItem } from './overview_item';

Expand All @@ -24,17 +27,20 @@ export function SyntheticsIndicatorOverview({ slo }: Props) {
},
} = useKibana().services;

const locator = locators.get(syntheticsMonitorDetailLocatorID);
const monitorLocator = locators.get(syntheticsMonitorDetailLocatorID);
const regionLocator = locators.get(syntheticsMonitorLocationQueryLocatorID);

const { 'monitor.name': name, 'observer.geo.name': location } = slo.groupings;
const { configId, locationId } = slo.meta?.synthetics || {};

const { locationId, monitorId } = slo.meta?.synthetics || {};

const indicator = slo.indicator;
if (!syntheticsAvailabilityIndicatorSchema.is(indicator)) {
return null;
}

const onMonitorClick = () => locator?.navigate({ configId, locationId });
const onMonitorClick = () => monitorLocator?.navigate({ configId: monitorId, locationId });
const onLocationClick = () => regionLocator?.navigate({ locationId: location });
const showOverviewItem = name || location;

if (!showOverviewItem) {
Expand Down Expand Up @@ -64,7 +70,13 @@ export function SyntheticsIndicatorOverview({ slo }: Props) {
)}
{location && (
<EuiFlexItem grow={false}>
<EuiBadge color="hollow">
<EuiBadge
color="hollow"
onClick={onLocationClick}
iconOnClick={onLocationClick}
onClickAriaLabel={LOCATION_ARIA_LABEL}
iconOnClickAriaLabel={LOCATION_ARIA_LABEL}
>
{i18n.translate('xpack.slo.sloDetails.overview.syntheticsMonitor.locationName', {
defaultMessage: 'Location: {value}',
values: { value: location },
Expand All @@ -88,3 +100,10 @@ const MONITOR_ARIA_LABEL = i18n.translate(
defaultMessage: 'Synthetics monitor details',
}
);

const LOCATION_ARIA_LABEL = i18n.translate(
'xpack.slo.sloDetails.overview.syntheticsLocationGroup',
{
defaultMessage: 'View all monitors in this location',
}
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* 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 { syntheticsMonitorLocationQueryLocatorID } from '@kbn/observability-plugin/common';

async function navigate({ locationId }: { locationId: string }) {
const locations = encodeURIComponent(JSON.stringify([locationId]));

return {
app: 'synthetics',
path: `?locations=${[locations]}`,
state: {},
};
}

export const monitorLocationNavigatorParams = {
id: syntheticsMonitorLocationQueryLocatorID,
getLocation: navigate,
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import { SerializableRecord } from '@kbn/utility-types';
import { monitorDetailNavigatorParams } from './monitor_detail';
import { editMonitorNavigatorParams } from './edit_monitor';
import { syntheticsSettingsNavigatorParams } from './settings';
import { monitorLocationNavigatorParams } from './group_monitor_by_location';

export const locators: Array<Pick<LocatorPublic<SerializableRecord>, 'id' | 'getLocation'>> = [
monitorDetailNavigatorParams,
monitorLocationNavigatorParams,
editMonitorNavigatorParams,
syntheticsSettingsNavigatorParams,
];

0 comments on commit 852a008

Please sign in to comment.