feat: add grafana link

This commit is contained in:
jialin
2026-02-04 20:14:25 +08:00
parent 7fd2b43704
commit 8690de00a9
13 changed files with 87 additions and 14 deletions
@@ -11,6 +11,7 @@ import { HandlerOptions } from '@/hooks/use-chunk-fetch';
import useDownloadStream from '@/hooks/use-download-stream';
import { useBenchmarkTargetInstance } from '@/pages/llmodels/hooks/use-run-benchmark';
import { ListItem as WorkerListItem } from '@/pages/resources/config/types';
import useGranfanaLink from '@/pages/resources/hooks/use-grafana-link';
import { convertFileSize } from '@/utils';
import {
DeleteOutlined,
@@ -327,6 +328,12 @@ const childActionList = [
],
icon: <IconFont type="icon-logs" />
},
{
label: 'resources.metrics.details',
key: 'metrics',
status: [InstanceStatusMap.Running],
icon: <IconFont type="icon-metrics" />
},
{
label: 'common.button.downloadLog',
key: 'download',
@@ -428,6 +435,7 @@ const InstanceItem: React.FC<InstanceItemProps> = ({
defaultOpenId,
handleChildSelect
}) => {
const { goToGrafana } = useGranfanaLink({ type: 'instance' });
const { runBenchmarkOnInstance } = useBenchmarkTargetInstance();
const [api, contextHolder] = notification.useNotification({
stack: { threshold: 1 }
@@ -689,6 +697,8 @@ const InstanceItem: React.FC<InstanceItemProps> = ({
filename: createFileName(instanceData.name),
downloadNotification
});
} else if (val === 'metrics') {
goToGrafana(instanceData);
} else {
handleChildSelect(val, instanceData);
}
+7 -1
View File
@@ -9,7 +9,6 @@ import SealTable from '@/components/seal-table';
import { TableOrder } from '@/components/seal-table/types';
import { PageAction } from '@/config';
import { TABLE_SORT_DIRECTIONS } from '@/config/settings';
import { PageActionType } from '@/config/types';
import useBodyScroll from '@/hooks/use-body-scroll';
import useExpandedRowKeys from '@/hooks/use-expanded-row-keys';
import useTableRowSelection from '@/hooks/use-table-row-selection';
@@ -18,6 +17,7 @@ import useNoResourceResult from '@/pages/llmodels/hooks/use-no-resource-result';
import { TargetStatusValueMap } from '@/pages/model-routes/config';
import useOpenPlayground from '@/pages/model-routes/hooks/use-open-playground';
import useQueryTargets from '@/pages/model-routes/services/use-query-targets';
import useGranfanaLink from '@/pages/resources/hooks/use-grafana-link';
import { handleBatchRequest } from '@/utils';
import { DownOutlined, SearchOutlined, SyncOutlined } from '@ant-design/icons';
import { useIntl, useNavigate, useSearchParams } from '@umijs/max';
@@ -170,6 +170,9 @@ const Models: React.FC<ModelsProps> = ({
useEffect(() => {
fetchTargets({});
}, []);
const { goToGrafana } = useGranfanaLink({
type: 'model'
});
const [openLogModal, setOpenLogModal] = useState(false);
const [openDeployModal, setOpenDeployModal] = useState<{
@@ -451,6 +454,9 @@ const Models: React.FC<ModelsProps> = ({
name: targetRoute?.route_name || ''
});
}
if (val === 'metrics') {
goToGrafana(row);
}
} catch (error) {
// ignore
}
@@ -39,6 +39,11 @@ export const ActionList: ActionItem[] = [
key: 'edit',
icon: icons.EditOutlined
},
{
label: 'resources.metrics.details',
key: 'metrics',
icon: icons.Metrics
},
{
label: 'models.openinplayground',
key: 'chat',
-1
View File
@@ -35,7 +35,6 @@ const Models: React.FC<{ clusterId?: number }> = ({ clusterId }) => {
loadend: false,
total: 0
});
const chunkRequedtRef = useRef<any>();
const chunkInstanceRequedtRef = useRef<any>();
const isPageHidden = useRef(false);
+4 -5
View File
@@ -8,6 +8,7 @@ import { DockerStepsFromWorker } from '@/pages/cluster-management/components/add
import { ClusterListItem } from '@/pages/cluster-management/config/types';
import useAddWorker from '@/pages/cluster-management/hooks/use-add-worker';
import useNoResourceResult from '@/pages/llmodels/hooks/use-no-resource-result';
import useGranfanaLink from '@/pages/resources/hooks/use-grafana-link';
import { useIntl } from '@umijs/max';
import { useMemoizedFn } from 'ahooks';
import { ConfigProvider, Table, message } from 'antd';
@@ -20,7 +21,6 @@ import {
updateWorker
} from '../apis';
import { ListItem } from '../config/types';
import useTerminalTabs from '../hooks/use-terminal-tabs';
import useWorkerColumns from '../hooks/use-worker-columns';
import useWorkerMaintenance from '../hooks/use-worker-maintenance';
import UpdateLabels from './update-labels';
@@ -65,7 +65,7 @@ const Workers: React.FC<{
cluster_id: clusterId
}
});
const { TerminalPanel, terminals, handleAddTerminal } = useTerminalTabs();
const { goToGrafana } = useGranfanaLink({ type: 'worker' });
const { MaintenanceModal, handleStopMaintenance, setOpenStatus } =
useWorkerMaintenance({ fetchData: handleSearch });
@@ -199,9 +199,8 @@ const Workers: React.FC<{
if (val === 'stop_maintenance') {
handleStopMaintenance(record);
}
if (val === 'terminal') {
handleAddTerminal(record);
if (val === 'metrics') {
goToGrafana(record);
}
});
@@ -0,0 +1,42 @@
import { GPUSTACK_API_BASE_URL } from '@/config/settings';
const useGranfanaLink = (options: {
type: 'model' | 'worker' | 'instance';
}) => {
const goToModelGrafana = (row: { id: number }) => {
window.open(
`/${GPUSTACK_API_BASE_URL}/models/${row.id}/dashboard`,
'_blank'
);
};
const goToWorkerGrafana = (row: { id: number }) => {
window.open(
`/${GPUSTACK_API_BASE_URL}/workers/${row.id}/dashboard`,
'_blank'
);
};
const goToInstanceGrafana = (row: { id: number }) => {
window.open(
`/${GPUSTACK_API_BASE_URL}/model-instances/${row.id}/dashboard`,
'_blank'
);
};
const goToGrafana = (row: { id: number }) => {
if (options.type === 'model') {
goToModelGrafana(row);
} else if (options.type === 'worker') {
goToWorkerGrafana(row);
} else if (options.type === 'instance') {
goToInstanceGrafana(row);
}
};
return {
goToGrafana
};
};
export default useGranfanaLink;
@@ -1,5 +1,6 @@
import AutoTooltip from '@/components/auto-tooltip';
import DropdownButtons from '@/components/drop-down-buttons';
import IconFont from '@/components/icon-font';
import LabelsCell from '@/components/label-cell';
import ProgressBar from '@/components/progress-bar';
import InfoColumn from '@/components/simple-table/info-column';
@@ -42,6 +43,11 @@ const IPWrapper = styled.span`
const ActionList = [
{ label: 'common.button.edit', key: 'edit', icon: <EditOutlined /> },
{
label: 'resources.metrics.details',
key: 'metrics',
icon: <IconFont type="icon-metrics" />
},
// {
// label: 'common.button.detail',
// key: 'details',