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', 'v1-openai',
'version', 'version',
'proxy', 'proxy',
'update' 'update',
'grafana'
]; ];
// @ts-ingore // @ts-ingore
+4 -2
View File
@@ -1,11 +1,13 @@
import { atom } from 'jotai'; import { atom } from 'jotai';
export interface SystemConfig { export interface SystemConfig {
grafana_url: string;
disable_builtin_observability: boolean; disable_builtin_observability: boolean;
debug: boolean; debug: boolean;
grafana_url: string; grafana_model_dashboard_uid: string;
server_external_url: string | null; grafana_worker_dashboard_uid: string;
system_default_container_registry: string | null; system_default_container_registry: string | null;
server_external_url: string | null;
showMonitoring?: boolean; showMonitoring?: boolean;
} }
+1 -2
View File
@@ -74,8 +74,7 @@ const Clusters: React.FC = () => {
}); });
const navigate = useNavigate(); const navigate = useNavigate();
const { goToGrafana, ActionButton } = useGranfanaLink({ const { goToGrafana, ActionButton } = useGranfanaLink({
type: 'cluster', type: 'cluster'
dataList: dataSource.dataList || []
}); });
const { watchDataList: allWorkerPoolList } = useWatchList(WORKER_POOLS_API); const { watchDataList: allWorkerPoolList } = useWatchList(WORKER_POOLS_API);
const [expandAtom] = useAtom(expandKeysAtom); 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 { watchDataList: targetList } = useWatchList(MODEL_ROUTE_TARGETS);
const { goToGrafana, ActionButton } = useGranfanaLink({ const { goToGrafana, ActionButton } = useGranfanaLink({
type: 'model', type: 'model'
dataList: dataSource || []
}); });
const [openLogModal, setOpenLogModal] = useState(false); const [openLogModal, setOpenLogModal] = useState(false);
+1 -2
View File
@@ -67,8 +67,7 @@ const Workers: React.FC<{
} }
}); });
const { goToGrafana, ActionButton } = useGranfanaLink({ const { goToGrafana, ActionButton } = useGranfanaLink({
type: 'worker', type: 'worker'
dataList: dataSource.dataList || []
}); });
const { MaintenanceModal, handleStopMaintenance, setOpenStatus } = const { MaintenanceModal, handleStopMaintenance, setOpenStatus } =
useWorkerMaintenance({ fetchData: handleSearch }); useWorkerMaintenance({ fetchData: handleSearch });
+17 -3
View File
@@ -7,11 +7,12 @@ import { useAtomValue } from 'jotai';
const useGranfanaLink = (options: { const useGranfanaLink = (options: {
type: 'model' | 'worker' | 'instance' | 'cluster'; type: 'model' | 'worker' | 'instance' | 'cluster';
dataList?: any[];
}) => { }) => {
const intl = useIntl(); const intl = useIntl();
const systemConfig = useAtomValue(systemConfigAtom); const systemConfig = useAtomValue(systemConfigAtom);
const grafanaUrl = systemConfig.grafana_url || 'grafana';
// for worker/model/instance/cluster item entry
const goToModelGrafana = (row: { id: number }) => { const goToModelGrafana = (row: { id: number }) => {
window.open( window.open(
`/${GPUSTACK_API_BASE_URL}/models/${row.id}/dashboard`, `/${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 = () => { const handleClick = () => {
if (options.dataList && options.dataList.length > 0) { if (options.type === 'model') {
goToGrafana(options.dataList?.[0]); modelEntry();
} else if (options.type === 'worker' || options.type === 'cluster') {
workerEntry();
} }
}; };