// 监控指标目录 — 主机/中间件/站点拨测可采集指标 // Logan.Li import { useEffect, useState } from 'react'; import { Card, CardContent } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; import { Button } from '@/components/ui/button'; import { Loader2, RefreshCw, Server, Database, Globe, Network } from 'lucide-react'; import { alertMetricsApi, type MetricCatalogCategory } from '@/api'; const CATEGORY_ORDER = ['host', 'middleware', 'snmp', 'site']; const categoryIcons: Record = { host: Server, middleware: Database, snmp: Network, site: Globe, }; export function MetricCatalogTab() { const [categories, setCategories] = useState([]); const [loading, setLoading] = useState(true); const [activeCat, setActiveCat] = useState('host'); const load = async () => { setLoading(true); try { const data = await alertMetricsApi.getCatalog(); const cats = (data as { categories?: MetricCatalogCategory[] })?.categories || []; setCategories(cats); if (cats.length > 0 && !cats.find(c => c.id === activeCat)) { setActiveCat(cats[0].id); } } catch { /* ignore */ } finally { setLoading(false); } }; useEffect(() => { load(); }, []); const current = categories.find(c => c.id === activeCat); if (loading) { return (
); } return (

主机 / 中间件 / SNMP / 站点拨测可采集指标,含默认告警阈值参考

{[...categories].sort((a, b) => { const ai = CATEGORY_ORDER.indexOf(a.id); const bi = CATEGORY_ORDER.indexOf(b.id); return (ai < 0 ? 99 : ai) - (bi < 0 ? 99 : bi); }).map(cat => { const Icon = categoryIcons[cat.id] || Server; return ( ); })}
{current && (

{current.description}

{current.metrics.map(m => ( ))}
指标 单位 类型 警告阈值 严重阈值 上限 说明
{m.label}
{m.key}
{m.unit || '—'} {m.type} {m.default_op} {m.default_warn}{m.unit && m.unit !== '' ? m.unit : ''} {m.default_op} {m.default_crit}{m.unit && m.unit !== '' ? m.unit : ''} {m.max} {m.description}
)}
); }