From 535a9ed0596e897a9dfd5bea5add324e6c81b21a Mon Sep 17 00:00:00 2001 From: Dima Lazerka <58356625+dima-vm@users.noreply.github.com> Date: Tue, 20 Aug 2024 15:30:38 -0400 Subject: [PATCH] vmui: Fix initial serverUrl for vmanomaly (#6834) - fix TS lint - anomaly: remove /vmui - anomaly: minor inspections fix - docs: fix broken links to headings ### Describe Your Changes Initially vmanomaly opened with `/vmui` in serverUrl, remove it. --- app/vmui/packages/vmui/src/AppAnomaly.tsx | 4 ++-- app/vmui/packages/vmui/src/assets/MetricsQL.md | 9 ++++----- .../vmui/src/components/ExploreAnomaly/AnomalyConfig.tsx | 2 +- app/vmui/packages/vmui/src/hooks/useSortedCategories.ts | 6 +++--- app/vmui/packages/vmui/src/utils/default-server-url.ts | 2 +- docs/MetricsQL.md | 8 ++++---- 6 files changed, 15 insertions(+), 16 deletions(-) diff --git a/app/vmui/packages/vmui/src/AppAnomaly.tsx b/app/vmui/packages/vmui/src/AppAnomaly.tsx index de139cd983618..4b8757c88f178 100644 --- a/app/vmui/packages/vmui/src/AppAnomaly.tsx +++ b/app/vmui/packages/vmui/src/AppAnomaly.tsx @@ -7,7 +7,7 @@ import ExploreAnomaly from "./pages/ExploreAnomaly/ExploreAnomaly"; import router from "./router"; import CustomPanel from "./pages/CustomPanel"; -const AppLogs: FC = () => { +const AppAnomaly: FC = () => { const [loadedTheme, setLoadedTheme] = useState(false); return <> @@ -38,4 +38,4 @@ const AppLogs: FC = () => { ; }; -export default AppLogs; +export default AppAnomaly; \ No newline at end of file diff --git a/app/vmui/packages/vmui/src/assets/MetricsQL.md b/app/vmui/packages/vmui/src/assets/MetricsQL.md index 64b343f5370a2..2f71686b58db0 100644 --- a/app/vmui/packages/vmui/src/assets/MetricsQL.md +++ b/app/vmui/packages/vmui/src/assets/MetricsQL.md @@ -1,5 +1,4 @@ --- -sort: 23 weight: 23 title: MetricsQL menu: @@ -546,7 +545,7 @@ while [increase](#increase) ignores the first value in a series if it is too big This function is usually applied to [counters](https://docs.victoriametrics.com/keyconcepts/#counter). -See also [increase](#increas) and [increase_prometheus](#increase_prometheus). +See also [increase](#increase) and [increase_prometheus](#increase_prometheus). #### increases_over_time @@ -955,7 +954,7 @@ See also [stddev_over_time](#stddev_over_time). #### sum_eq_over_time -`sum_eq_over_time(series_selector[d], eq)` is a [rollup function](#rollup-function), which calculates the sum of [raw sample](https://docs.victoriametrics.com/keyconcepts/#raw-samples) +`sum_eq_over_time(series_selector[d], eq)` is a [rollup function](#rollup-functions), which calculates the sum of [raw sample](https://docs.victoriametrics.com/keyconcepts/#raw-samples) values equal to `eq` on the given lookbehind window `d` per each time series returned from the given [series_selector](https://docs.victoriametrics.com/keyconcepts/#filtering). Metric names are stripped from the resulting rollups. Add [keep_metric_names](#keep_metric_names) modifier in order to keep metric names. @@ -966,7 +965,7 @@ See also [sum_over_time](#sum_over_time) and [count_eq_over_time](#count_eq_over #### sum_gt_over_time -`sum_gt_over_time(series_selector[d], gt)` is a [rollup function](#rollup-function), which calculates the sum of [raw sample](https://docs.victoriametrics.com/keyconcepts/#raw-samples) +`sum_gt_over_time(series_selector[d], gt)` is a [rollup function](#rollup-functions), which calculates the sum of [raw sample](https://docs.victoriametrics.com/keyconcepts/#raw-samples) values bigger than `gt` on the given lookbehind window `d` per each time series returned from the given [series_selector](https://docs.victoriametrics.com/keyconcepts/#filtering). Metric names are stripped from the resulting rollups. Add [keep_metric_names](#keep_metric_names) modifier in order to keep metric names. @@ -977,7 +976,7 @@ See also [sum_over_time](#sum_over_time) and [count_gt_over_time](#count_gt_over #### sum_le_over_time -`sum_le_over_time(series_selector[d], le)` is a [rollup function](#rollup-function), which calculates the sum of [raw sample](https://docs.victoriametrics.com/keyconcepts/#raw-samples) +`sum_le_over_time(series_selector[d], le)` is a [rollup function](#rollup-functions), which calculates the sum of [raw sample](https://docs.victoriametrics.com/keyconcepts/#raw-samples) values smaller or equal to `le` on the given lookbehind window `d` per each time series returned from the given [series_selector](https://docs.victoriametrics.com/keyconcepts/#filtering). Metric names are stripped from the resulting rollups. Add [keep_metric_names](#keep_metric_names) modifier in order to keep metric names. diff --git a/app/vmui/packages/vmui/src/components/ExploreAnomaly/AnomalyConfig.tsx b/app/vmui/packages/vmui/src/components/ExploreAnomaly/AnomalyConfig.tsx index 8bd78a84f6496..2d251337f8ac5 100644 --- a/app/vmui/packages/vmui/src/components/ExploreAnomaly/AnomalyConfig.tsx +++ b/app/vmui/packages/vmui/src/components/ExploreAnomaly/AnomalyConfig.tsx @@ -63,7 +63,7 @@ const AnomalyConfig: FC = () => { URL.revokeObjectURL(downloadUrl); setTextConfig(""); setDownloadUrl(""); - fetchConfig(); + return fetchConfig(); }; return ( diff --git a/app/vmui/packages/vmui/src/hooks/useSortedCategories.ts b/app/vmui/packages/vmui/src/hooks/useSortedCategories.ts index 92324925c3bc3..e284fb5992915 100644 --- a/app/vmui/packages/vmui/src/hooks/useSortedCategories.ts +++ b/app/vmui/packages/vmui/src/hooks/useSortedCategories.ts @@ -1,5 +1,5 @@ -import {useMemo} from "preact/compat"; -import {MetricBase} from "../api/types"; +import { useMemo } from "preact/compat"; +import { MetricBase } from "../api/types"; export type MetricCategory = { key: string; @@ -10,7 +10,7 @@ export const getColumns = (data: MetricBase[]): MetricCategory[] => { const columns: { [key: string]: { options: Set } } = {}; data.forEach(d => Object.entries(d.metric).forEach(e => - columns[e[0]] ? columns[e[0]].options.add(e[1]) : columns[e[0]] = {options: new Set([e[1]])} + columns[e[0]] ? columns[e[0]].options.add(e[1]) : columns[e[0]] = { options: new Set([e[1]]) } ) ); diff --git a/app/vmui/packages/vmui/src/utils/default-server-url.ts b/app/vmui/packages/vmui/src/utils/default-server-url.ts index 7a23b6443390f..e78a6ef14a681 100644 --- a/app/vmui/packages/vmui/src/utils/default-server-url.ts +++ b/app/vmui/packages/vmui/src/utils/default-server-url.ts @@ -8,7 +8,7 @@ export const getDefaultServer = (tenantId?: string): string => { const { serverURL } = getAppModeParams(); const storageURL = getFromStorage("SERVER_URL") as string; const logsURL = window.location.href.replace(/\/(select\/)?(vmui)\/.*/, ""); - const anomalyURL = `${window.location.origin}${window.location.pathname}`; + const anomalyURL = `${window.location.origin}${window.location.pathname.replace(/^\/vmui/, "")}`; const defaultURL = window.location.href.replace(/\/(?:prometheus\/)?(?:graph|vmui)\/.*/, "/prometheus"); const url = serverURL || storageURL || defaultURL; diff --git a/docs/MetricsQL.md b/docs/MetricsQL.md index c562b7216f12d..2f71686b58db0 100644 --- a/docs/MetricsQL.md +++ b/docs/MetricsQL.md @@ -545,7 +545,7 @@ while [increase](#increase) ignores the first value in a series if it is too big This function is usually applied to [counters](https://docs.victoriametrics.com/keyconcepts/#counter). -See also [increase](#increas) and [increase_prometheus](#increase_prometheus). +See also [increase](#increase) and [increase_prometheus](#increase_prometheus). #### increases_over_time @@ -954,7 +954,7 @@ See also [stddev_over_time](#stddev_over_time). #### sum_eq_over_time -`sum_eq_over_time(series_selector[d], eq)` is a [rollup function](#rollup-function), which calculates the sum of [raw sample](https://docs.victoriametrics.com/keyconcepts/#raw-samples) +`sum_eq_over_time(series_selector[d], eq)` is a [rollup function](#rollup-functions), which calculates the sum of [raw sample](https://docs.victoriametrics.com/keyconcepts/#raw-samples) values equal to `eq` on the given lookbehind window `d` per each time series returned from the given [series_selector](https://docs.victoriametrics.com/keyconcepts/#filtering). Metric names are stripped from the resulting rollups. Add [keep_metric_names](#keep_metric_names) modifier in order to keep metric names. @@ -965,7 +965,7 @@ See also [sum_over_time](#sum_over_time) and [count_eq_over_time](#count_eq_over #### sum_gt_over_time -`sum_gt_over_time(series_selector[d], gt)` is a [rollup function](#rollup-function), which calculates the sum of [raw sample](https://docs.victoriametrics.com/keyconcepts/#raw-samples) +`sum_gt_over_time(series_selector[d], gt)` is a [rollup function](#rollup-functions), which calculates the sum of [raw sample](https://docs.victoriametrics.com/keyconcepts/#raw-samples) values bigger than `gt` on the given lookbehind window `d` per each time series returned from the given [series_selector](https://docs.victoriametrics.com/keyconcepts/#filtering). Metric names are stripped from the resulting rollups. Add [keep_metric_names](#keep_metric_names) modifier in order to keep metric names. @@ -976,7 +976,7 @@ See also [sum_over_time](#sum_over_time) and [count_gt_over_time](#count_gt_over #### sum_le_over_time -`sum_le_over_time(series_selector[d], le)` is a [rollup function](#rollup-function), which calculates the sum of [raw sample](https://docs.victoriametrics.com/keyconcepts/#raw-samples) +`sum_le_over_time(series_selector[d], le)` is a [rollup function](#rollup-functions), which calculates the sum of [raw sample](https://docs.victoriametrics.com/keyconcepts/#raw-samples) values smaller or equal to `le` on the given lookbehind window `d` per each time series returned from the given [series_selector](https://docs.victoriametrics.com/keyconcepts/#filtering). Metric names are stripped from the resulting rollups. Add [keep_metric_names](#keep_metric_names) modifier in order to keep metric names.