chore: grafana entry

This commit is contained in:
jialin
2026-02-06 14:27:05 +08:00
parent 7f3d6bb55f
commit 4ff5b3e05a
6 changed files with 26 additions and 12 deletions
+2 -1
View File
@@ -6,7 +6,8 @@ const proxyTableList = [
'v1-openai',
'version',
'proxy',
'update'
'update',
'grafana'
];
// @ts-ingore
+4 -2
View File
@@ -1,11 +1,13 @@
import { atom } from 'jotai';
export interface SystemConfig {
grafana_url: string;
disable_builtin_observability: boolean;
debug: boolean;
grafana_url: string;
server_external_url: string | null;
grafana_model_dashboard_uid: string;
grafana_worker_dashboard_uid: string;
system_default_container_registry: string | null;
server_external_url: string | null;
showMonitoring?: boolean;
}
+1 -2
View File
@@ -74,8 +74,7 @@ const Clusters: React.FC = () => {
});
const navigate = useNavigate();
const { goToGrafana, ActionButton } = useGranfanaLink({
type: 'cluster',
dataList: dataSource.dataList || []
type: 'cluster'
});
const { watchDataList: allWorkerPoolList } = useWatchList(WORKER_POOLS_API);
const [expandAtom] = useAtom(expandKeysAtom);
+1 -2
View File
@@ -170,8 +170,7 @@ const Models: React.FC<ModelsProps> = ({
const { watchDataList: targetList } = useWatchList(MODEL_ROUTE_TARGETS);
const { goToGrafana, ActionButton } = useGranfanaLink({
type: 'model',
dataList: dataSource || []
type: 'model'
});
const [openLogModal, setOpenLogModal] = useState(false);
+1 -2
View File
@@ -67,8 +67,7 @@ const Workers: React.FC<{
}
});
const { goToGrafana, ActionButton } = useGranfanaLink({
type: 'worker',
dataList: dataSource.dataList || []
type: 'worker'
});
const { MaintenanceModal, handleStopMaintenance, setOpenStatus } =
useWorkerMaintenance({ fetchData: handleSearch });
+17 -3
View File
@@ -7,11 +7,12 @@ import { useAtomValue } from 'jotai';
const useGranfanaLink = (options: {
type: 'model' | 'worker' | 'instance' | 'cluster';
dataList?: any[];
}) => {
const intl = useIntl();
const systemConfig = useAtomValue(systemConfigAtom);
const grafanaUrl = systemConfig.grafana_url || 'grafana';
// for worker/model/instance/cluster item entry
const goToModelGrafana = (row: { id: number }) => {
window.open(
`/${GPUSTACK_API_BASE_URL}/models/${row.id}/dashboard`,
@@ -52,9 +53,22 @@ const useGranfanaLink = (options: {
}
};
// all endpoints of grafana
const modelEntry = () => {
const modelURL = systemConfig.grafana_model_dashboard_uid;
window.open(`${grafanaUrl}/d/${modelURL}/gpustack-model`, '_blank');
};
const workerEntry = () => {
const workerURL = systemConfig.grafana_worker_dashboard_uid;
window.open(`${grafanaUrl}/d/${workerURL}/gpustack-worker`, '_blank');
};
const handleClick = () => {
if (options.dataList && options.dataList.length > 0) {
goToGrafana(options.dataList?.[0]);
if (options.type === 'model') {
modelEntry();
} else if (options.type === 'worker' || options.type === 'cluster') {
workerEntry();
}
};