chore: grafana entry
This commit is contained in:
+4
-2
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 });
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user