From ec2b24f3f3e63de4f6568084bd29bb889d2fa659 Mon Sep 17 00:00:00 2001 From: Yury Molodov Date: Fri, 23 Dec 2022 00:24:40 +0100 Subject: [PATCH] vmui: add explore tab for exploration of metrics, which belong to a particular job/instance (#3470) * feat: add "Explore" page * feat: add graphs for explore page * vmui: add explore tab for exploration of metrics, which belong to a particular job/instance * refactor: rename variables * refactor: extract graph to ExploreMetricItemGraph.tsx * feat: add searchable for Select.tsx * feat: improve metrics explorer * feat: set document title by page * feat: add page to view icons * fix: improve styles * fix: add encodeURIComponent to query --- app/vmui/packages/vmui/.env | 1 + app/vmui/packages/vmui/README.md | 3 +- app/vmui/packages/vmui/src/App.tsx | 10 ++ .../packages/vmui/src/api/explore-metrics.ts | 16 ++ .../src/components/Layout/Footer/Footer.tsx | 4 +- .../src/components/Layout/Footer/style.scss | 10 -- .../src/components/Layout/Header/Header.tsx | 14 +- .../vmui/src/components/Layout/Layout.tsx | 12 +- .../Main/Autocomplete/Autocomplete.tsx | 14 +- .../components/Main/Autocomplete/style.scss | 6 + .../components/Main/Icons/PreviewIcons.tsx | 38 +++++ .../vmui/src/components/Main/Icons/index.tsx | 20 +-- .../vmui/src/components/Main/Icons/style.scss | 53 +++++++ .../vmui/src/components/Main/Modal/style.scss | 2 +- .../src/components/Main/Popper/Popper.tsx | 13 +- .../src/components/Main/Select/Select.tsx | 120 +++++++++++++++ .../src/components/Main/Select/style.scss | 50 ++++++ .../src/components/Main/Switch/Switch.tsx | 4 +- .../components/Main/TextField/TextField.tsx | 27 +++- .../src/components/Main/TextField/style.scss | 2 +- .../TraceQuery/NestedNav/NestedNav.tsx | 4 +- .../ExploreMetricItem/ExploreMetricItem.tsx | 80 ++++++++++ .../ExploreMetricItemGraph.tsx | 111 ++++++++++++++ .../ExploreMetricItem/style.scss | 36 +++++ .../ExploreMetrics/hooks/useFetchInstances.ts | 50 ++++++ .../ExploreMetrics/hooks/useFetchJobs.ts | 49 ++++++ .../ExploreMetrics/hooks/useFetchNames.ts | 48 ++++++ .../ExploreMetrics/hooks/useSetQueryParams.ts | 22 +++ .../vmui/src/pages/ExploreMetrics/index.tsx | 142 ++++++++++++++++++ .../vmui/src/pages/ExploreMetrics/style.scss | 44 ++++++ .../vmui/src/pages/TracePage/index.tsx | 8 +- .../vmui/src/pages/TracePage/style.scss | 2 +- app/vmui/packages/vmui/src/router/index.ts | 34 ++++- .../vmui/src/styles/components/link.scss | 15 ++ app/vmui/packages/vmui/src/styles/style.scss | 3 +- .../packages/vmui/src/styles/variables.scss | 2 +- docs/CHANGELOG.md | 1 + 37 files changed, 1020 insertions(+), 50 deletions(-) create mode 100644 app/vmui/packages/vmui/.env create mode 100644 app/vmui/packages/vmui/src/api/explore-metrics.ts create mode 100644 app/vmui/packages/vmui/src/components/Main/Icons/PreviewIcons.tsx create mode 100644 app/vmui/packages/vmui/src/components/Main/Icons/style.scss create mode 100644 app/vmui/packages/vmui/src/components/Main/Select/Select.tsx create mode 100644 app/vmui/packages/vmui/src/components/Main/Select/style.scss create mode 100644 app/vmui/packages/vmui/src/pages/ExploreMetrics/ExploreMetricItem/ExploreMetricItem.tsx create mode 100644 app/vmui/packages/vmui/src/pages/ExploreMetrics/ExploreMetricItem/ExploreMetricItemGraph.tsx create mode 100644 app/vmui/packages/vmui/src/pages/ExploreMetrics/ExploreMetricItem/style.scss create mode 100644 app/vmui/packages/vmui/src/pages/ExploreMetrics/hooks/useFetchInstances.ts create mode 100644 app/vmui/packages/vmui/src/pages/ExploreMetrics/hooks/useFetchJobs.ts create mode 100644 app/vmui/packages/vmui/src/pages/ExploreMetrics/hooks/useFetchNames.ts create mode 100644 app/vmui/packages/vmui/src/pages/ExploreMetrics/hooks/useSetQueryParams.ts create mode 100644 app/vmui/packages/vmui/src/pages/ExploreMetrics/index.tsx create mode 100644 app/vmui/packages/vmui/src/pages/ExploreMetrics/style.scss create mode 100644 app/vmui/packages/vmui/src/styles/components/link.scss diff --git a/app/vmui/packages/vmui/.env b/app/vmui/packages/vmui/.env new file mode 100644 index 0000000000..39cc24b68d --- /dev/null +++ b/app/vmui/packages/vmui/.env @@ -0,0 +1 @@ +FAST_REFRESH=false \ No newline at end of file diff --git a/app/vmui/packages/vmui/README.md b/app/vmui/packages/vmui/README.md index fef9a3c8a6..55328dc460 100644 --- a/app/vmui/packages/vmui/README.md +++ b/app/vmui/packages/vmui/README.md @@ -9,7 +9,8 @@ In the project directory, you can run: ### `npm start` Runs the app in the development mode.\ -Open [http://localhost:3000](http://localhost:3000) to view it in the browser. +Open [http://localhost:3000](http://localhost:3000) to view it in the browser.\ +Open [http://localhost:3000/#/icons](http://localhost:3000/#/icons) to view the icons used in the project. The page will reload if you make edits.\ You will also see any lint errors in the console. diff --git a/app/vmui/packages/vmui/src/App.tsx b/app/vmui/packages/vmui/src/App.tsx index 9709a1df55..86f0e3cea3 100644 --- a/app/vmui/packages/vmui/src/App.tsx +++ b/app/vmui/packages/vmui/src/App.tsx @@ -10,6 +10,8 @@ import TopQueries from "./pages/TopQueries"; import ThemeProvider from "./components/Main/ThemeProvider/ThemeProvider"; import Spinner from "./components/Main/Spinner/Spinner"; import TracePage from "./pages/TracePage"; +import ExploreMetrics from "./pages/ExploreMetrics"; +import PreviewIcons from "./components/Main/Icons/PreviewIcons"; const App: FC = () => { @@ -50,6 +52,14 @@ const App: FC = () => { path={router.trace} element={} /> + } + /> + } + /> diff --git a/app/vmui/packages/vmui/src/api/explore-metrics.ts b/app/vmui/packages/vmui/src/api/explore-metrics.ts new file mode 100644 index 0000000000..35713ed117 --- /dev/null +++ b/app/vmui/packages/vmui/src/api/explore-metrics.ts @@ -0,0 +1,16 @@ +import { TimeParams } from "../types"; + +export const getJobsUrl = (server: string, period: TimeParams): string => + `${server}/api/v1/label/job/values?start=${period.start}&end=${period.end}`; + +export const getInstancesUrl = (server: string, period: TimeParams, job: string): string => + `${server}/api/v1/label/instance/values?match[]={job="${encodeURIComponent(job)}"}&start=${period.start}&end=${period.end}`; + +export const getNamesUrl = (server: string, job: string, instance: string): string => { + const match = Object.entries({ job, instance }) + .filter(val => val[1]) + .map(([key, val]) => `${key}="${val}"`) + .join(","); + + return `${server}/api/v1/label/__name__/values?match[]={${encodeURIComponent(match)}}`; +}; diff --git a/app/vmui/packages/vmui/src/components/Layout/Footer/Footer.tsx b/app/vmui/packages/vmui/src/components/Layout/Footer/Footer.tsx index bd383a0544..451148fc15 100644 --- a/app/vmui/packages/vmui/src/components/Layout/Footer/Footer.tsx +++ b/app/vmui/packages/vmui/src/components/Layout/Footer/Footer.tsx @@ -8,7 +8,7 @@ const Footer: FC = () => { return