From bfb55d5f2f47dd3af199e33cf6180ca6680a8af4 Mon Sep 17 00:00:00 2001 From: Yury Molodov Date: Thu, 31 Oct 2024 13:43:58 +0100 Subject: [PATCH] vmui: fix the display of the link to vmalert (#7380) ### Describe Your Changes Fix the issue mentioned in https://github.com/VictoriaMetrics/VictoriaMetrics/pull/7088#issuecomment-2391360368 ### Checklist The following checks are **mandatory**: - [ ] My change adheres [VictoriaMetrics contributing guidelines](https://docs.victoriametrics.com/contributing/). --- app/vmui/packages/vmui/src/hooks/useFetchFlags.ts | 3 +-- app/vmui/packages/vmui/src/router/navigation.ts | 7 +++++-- docs/changelog/CHANGELOG.md | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/vmui/packages/vmui/src/hooks/useFetchFlags.ts b/app/vmui/packages/vmui/src/hooks/useFetchFlags.ts index 7c695323a..25162157c 100644 --- a/app/vmui/packages/vmui/src/hooks/useFetchFlags.ts +++ b/app/vmui/packages/vmui/src/hooks/useFetchFlags.ts @@ -1,7 +1,6 @@ import { useAppDispatch, useAppState } from "../state/common/StateContext"; import { useEffect, useState } from "preact/compat"; import { ErrorTypes } from "../types"; -import { getUrlWithoutTenant } from "../utils/tenants"; const useFetchFlags = () => { const { serverUrl } = useAppState(); @@ -17,7 +16,7 @@ const useFetchFlags = () => { setIsLoading(true); try { - const url = getUrlWithoutTenant(serverUrl); + const url = new URL(serverUrl).origin; const response = await fetch(`${url}/flags`); const data = await response.text(); const flags = data.split("\n").filter(flag => flag.trim() !== "") diff --git a/app/vmui/packages/vmui/src/router/navigation.ts b/app/vmui/packages/vmui/src/router/navigation.ts index bf96205fe..54ab01398 100644 --- a/app/vmui/packages/vmui/src/router/navigation.ts +++ b/app/vmui/packages/vmui/src/router/navigation.ts @@ -1,4 +1,5 @@ import router, { routerOptions } from "./index"; +import { getTenantIdFromUrl } from "../utils/tenants"; export enum NavigationItemType { internalLink, @@ -24,10 +25,12 @@ interface NavigationConfig { * Special case for alert link */ const getAlertLink = (url: string, showAlertLink: boolean) => { - // see more https://docs.victoriametrics.com/cluster-victoriametrics/?highlight=vmalertproxyurl#vmalert + // see more https://docs.victoriametrics.com/cluster-victoriametrics/#vmalert + const isCluster = !!getTenantIdFromUrl(url); + const value = isCluster ? `${url}/vmalert` : url.replace(/\/prometheus$/, "/vmalert"); return { label: "Alerts", - value: `${url}/vmalert`, + value, type: NavigationItemType.externalLink, hide: !showAlertLink, }; diff --git a/docs/changelog/CHANGELOG.md b/docs/changelog/CHANGELOG.md index 3e1bcfded..4f1e4f095 100644 --- a/docs/changelog/CHANGELOG.md +++ b/docs/changelog/CHANGELOG.md @@ -28,6 +28,7 @@ See also [LTS releases](https://docs.victoriametrics.com/lts-releases/). * BUGFIX: [vmalert](https://docs.victoriametrics.com/vmalert): properly set `group_name` and `file` fields for recording rules in `/api/v1/rules`. * BUGFIX: [Single-node VictoriaMetrics](https://docs.victoriametrics.com/) and `vmstorage` in [VictoriaMetrics cluster](https://docs.victoriametrics.com/cluster-victoriametrics/): prevent panic when ingesting samples which are outisde of configured [retention filters](https://docs.victoriametrics.com/#retention-filters). This could happen when backfilling data with retention filters which exclude samples from the backfill range. * BUGFIX: [vmctl](https://docs.victoriametrics.com/vmctl/): fix issue with series matching for `vmctl vm-native` with `--vm-native-disable-per-metric-migration` flag enabled. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/7309). +* BUGFIX: [vmui](https://docs.victoriametrics.com/#vmui): fix the display of the link to vmalert. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5924). ## [v1.105.0](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.105.0)