Skip to content

Commit 0c778f5

Browse files
authored
Add Server Metrics Info Tab (#2340)
1 parent 43db772 commit 0c778f5

20 files changed

+439
-277
lines changed

models/admin_info_response.go

Lines changed: 55 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

portal-ui/src/screens/Console/Common/FormComponents/DateRangeSelector/DateRangeSelector.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ const DateRangeSelector = ({
264264
alignItems: "flex-end",
265265
display: "flex",
266266
justifyContent: "flex-end",
267-
marginRight: "35px",
268267
}}
269268
>
270269
<Button

portal-ui/src/screens/Console/Dashboard/BasicDashboard/BasicDashboard.tsx

Lines changed: 43 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// You should have received a copy of the GNU Affero General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
import React, { Fragment } from "react";
17+
import React from "react";
1818
import { Box } from "@mui/material";
1919
import {
2020
ArrowRightIcon,
@@ -67,7 +67,7 @@ interface IDashboardProps {
6767

6868
const getServersList = (usage: Usage | null) => {
6969
if (usage !== null) {
70-
return usage.servers.sort(function (a, b) {
70+
return [...usage.servers].sort(function (a, b) {
7171
const nameA = a.endpoint.toLowerCase();
7272
const nameB = b.endpoint.toLowerCase();
7373
if (nameA < nameB) {
@@ -114,84 +114,17 @@ const BasicDashboard = ({ usage }: IDashboardProps) => {
114114
serversGroup;
115115
const drivesGroup = groupBy(allDrivesArray, "state");
116116
const { offline: offlineDrives = [], ok: onlineDrives = [] } = drivesGroup;
117-
118117
return (
119-
<Box
120-
sx={{
121-
maxWidth: "1536px",
122-
margin: "auto",
123-
}}
124-
>
118+
<Box>
125119
<Box
126120
sx={{
127121
display: "grid",
128122
gridTemplateRows: "1fr",
129123
gridTemplateColumns: "1fr",
130124
gap: "27px",
131125
marginBottom: "40px",
132-
marginTop: "40px",
133-
marginLeft: "40px",
134-
marginRight: "40px",
135126
}}
136127
>
137-
<Box>
138-
{usage?.prometheusNotReady && (
139-
<HelpBox
140-
iconComponent={<PrometheusErrorIcon />}
141-
title={"We can't retrieve advanced metrics at this time"}
142-
help={
143-
<Fragment>
144-
MinIO Dashboard will display basic metrics as we couldn't
145-
connect to Prometheus successfully.
146-
<br /> <br />
147-
Please try again in a few minutes. If the problem persists,
148-
you can review your configuration and confirm that Prometheus
149-
server is up and running.
150-
</Fragment>
151-
}
152-
/>
153-
)}
154-
155-
{!usage?.prometheusNotReady && (
156-
<HelpBox
157-
iconComponent={<PrometheusErrorIcon />}
158-
title={"We can’t retrieve advanced metrics at this time."}
159-
help={
160-
<Box>
161-
<Box
162-
sx={{
163-
fontSize: "14px",
164-
}}
165-
>
166-
MinIO Dashboard will display basic metrics as we couldn’t
167-
connect to Prometheus successfully. Please try again in a
168-
few minutes. If the problem persists, you can review your
169-
configuration and confirm that Prometheus server is up and
170-
running.
171-
</Box>
172-
<Box
173-
sx={{
174-
paddingTop: "20px",
175-
fontSize: "14px",
176-
"& a": {
177-
color: (theme) => theme.colors.link,
178-
},
179-
}}
180-
>
181-
<a
182-
href="https://min.io/docs/minio/linux/operations/monitoring/collect-minio-metrics-using-prometheus.html"
183-
target="_blank"
184-
rel="noreferrer"
185-
>
186-
Read more about Prometheus on our Docs site.
187-
</a>
188-
</Box>
189-
</Box>
190-
}
191-
/>
192-
)}
193-
</Box>
194-
195128
<Box
196129
sx={{
197130
display: "grid",
@@ -355,6 +288,46 @@ const BasicDashboard = ({ usage }: IDashboardProps) => {
355288
<ServersList data={serverList} />
356289
</Box>
357290
</Box>
291+
{usage?.advancedMetricsStatus === "not configured" && (
292+
<Box>
293+
<HelpBox
294+
iconComponent={<PrometheusErrorIcon />}
295+
title={"We can’t retrieve advanced metrics at this time."}
296+
help={
297+
<Box>
298+
<Box
299+
sx={{
300+
fontSize: "14px",
301+
}}
302+
>
303+
MinIO Dashboard will display basic metrics as we couldn’t
304+
connect to Prometheus successfully. Please try again in a
305+
few minutes. If the problem persists, you can review your
306+
configuration and confirm that Prometheus server is up and
307+
running.
308+
</Box>
309+
<Box
310+
sx={{
311+
paddingTop: "20px",
312+
fontSize: "14px",
313+
"& a": {
314+
color: (theme) => theme.colors.link,
315+
},
316+
}}
317+
>
318+
<a
319+
href="https://min.io/docs/minio/linux/operations/monitoring/collect-minio-metrics-using-prometheus.html"
320+
target="_blank"
321+
rel="noreferrer"
322+
>
323+
Read more about Prometheus on our Docs site.
324+
</a>
325+
</Box>
326+
</Box>
327+
}
328+
/>
329+
</Box>
330+
)}
358331
</Box>
359332
</Box>
360333
);

portal-ui/src/screens/Console/Dashboard/BasicDashboard/ServersList.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ const ServersList = ({ data }: { data: ServerInfo[] }) => {
7070
display: "flex",
7171
alignItems: "center",
7272
justifyContent: "space-between",
73-
border: "1px solid #f1f1f1",
73+
borderTop: index === 0 ? "1px solid #f1f1f1" : "",
74+
borderBottom: "1px solid #f1f1f1",
75+
borderLeft: "1px solid #f1f1f1",
76+
borderRight: "1px solid #f1f1f1",
7477
padding: "3px 10px 3px 10px",
7578

7679
"&:hover": {

portal-ui/src/screens/Console/Dashboard/Dashboard.tsx

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
// You should have received a copy of the GNU Affero General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
import React, { Fragment, useCallback, useEffect, useState } from "react";
18-
19-
import get from "lodash/get";
17+
import React, { Fragment, useEffect, useState } from "react";
2018
import PrDashboard from "./Prometheus/PrDashboard";
2119
import PageHeader from "../Common/PageHeader/PageHeader";
2220
import Grid from "@mui/material/Grid";
@@ -25,13 +23,9 @@ import { Theme } from "@mui/material/styles";
2523
import createStyles from "@mui/styles/createStyles";
2624
import withStyles from "@mui/styles/withStyles";
2725
import { LinearProgress } from "@mui/material";
28-
import api from "../../../common/api";
29-
import { Usage } from "./types";
30-
31-
import { ErrorResponseHandler } from "../../../common/types";
32-
import BasicDashboard from "./BasicDashboard/BasicDashboard";
33-
import { setErrorSnackMessage } from "../../../systemSlice";
34-
import { useAppDispatch } from "../../../store";
26+
import { AppState, useAppDispatch } from "../../../store";
27+
import { getUsageAsync } from "./dashboardThunks";
28+
import { useSelector } from "react-redux";
3529

3630
interface IDashboardSimple {
3731
classes: any;
@@ -45,28 +39,15 @@ const styles = (theme: Theme) =>
4539
const Dashboard = ({ classes }: IDashboardSimple) => {
4640
const dispatch = useAppDispatch();
4741
const [loading, setLoading] = useState<boolean>(true);
48-
const [basicResult, setBasicResult] = useState<Usage | null>(null);
4942

50-
const fetchUsage = useCallback(() => {
51-
api
52-
.invoke("GET", `/api/v1/admin/info`)
53-
.then((res: Usage) => {
54-
setBasicResult(res);
55-
setLoading(false);
56-
})
57-
.catch((err: ErrorResponseHandler) => {
58-
dispatch(setErrorSnackMessage(err));
59-
setLoading(false);
60-
});
61-
}, [setBasicResult, setLoading, dispatch]);
43+
const usage = useSelector((state: AppState) => state.dashboard.usage);
6244

6345
useEffect(() => {
6446
if (loading) {
65-
fetchUsage();
47+
setLoading(false);
48+
dispatch(getUsageAsync());
6649
}
67-
}, [loading, fetchUsage]);
68-
69-
const widgets = get(basicResult, "widgets", null);
50+
}, [loading, dispatch]);
7051

7152
return (
7253
<Fragment>
@@ -78,13 +59,7 @@ const Dashboard = ({ classes }: IDashboardSimple) => {
7859
</Grid>
7960
</Grid>
8061
) : (
81-
<Fragment>
82-
{widgets !== null ? (
83-
<PrDashboard />
84-
) : (
85-
<BasicDashboard usage={basicResult} />
86-
)}
87-
</Fragment>
62+
<PrDashboard usage={usage} />
8863
)}
8964
</Fragment>
9065
);

0 commit comments

Comments
 (0)