mirror of
https://github.com/ReCloudStudio/WebHooker.git
synced 2026-09-22 16:11:29 +00:00
feat(observability): delivery metrics, admin metrics/delivery endpoints, admin API route wiring
This commit is contained in:
parent
2470bd786d
commit
1e9ba3c5dd
17 changed files with 682 additions and 7 deletions
|
|
@ -17,6 +17,19 @@ const en: Dict = {
|
|||
"tab.groups": "Groups",
|
||||
"tab.logs": "Send Logs",
|
||||
"tab.audit": "Audit Log",
|
||||
"tab.metrics": "Metrics",
|
||||
"metrics.title": "Delivery Metrics",
|
||||
"metrics.refresh": "Refresh",
|
||||
"metrics.total": "Total",
|
||||
"metrics.ok": "OK",
|
||||
"metrics.failed": "Failed",
|
||||
"metrics.failureRate": "Failure rate",
|
||||
"metrics.avgDuration": "Avg duration",
|
||||
"metrics.avgAttempts": "Avg attempts",
|
||||
"metrics.byPlatform": "By platform",
|
||||
"metrics.byEvent": "By event",
|
||||
"metrics.recentFailures": "Recent failures",
|
||||
"metrics.empty": "No delivery data yet",
|
||||
"status.loading": "loading",
|
||||
"status.connected": "connected",
|
||||
"kpi.groups": "GROUPS",
|
||||
|
|
@ -281,6 +294,19 @@ const zh: Dict = {
|
|||
"tab.groups": "分组",
|
||||
"tab.logs": "发送日志",
|
||||
"tab.audit": "审计日志",
|
||||
"tab.metrics": "指标",
|
||||
"metrics.title": "投递指标",
|
||||
"metrics.refresh": "刷新",
|
||||
"metrics.total": "总计",
|
||||
"metrics.ok": "成功",
|
||||
"metrics.failed": "失败",
|
||||
"metrics.failureRate": "失败率",
|
||||
"metrics.avgDuration": "平均耗时",
|
||||
"metrics.avgAttempts": "平均尝试次数",
|
||||
"metrics.byPlatform": "按平台",
|
||||
"metrics.byEvent": "按事件",
|
||||
"metrics.recentFailures": "最近失败",
|
||||
"metrics.empty": "暂无投递数据",
|
||||
"status.loading": "加载中",
|
||||
"status.connected": "已连接",
|
||||
"kpi.groups": "分组",
|
||||
|
|
|
|||
24
app/composables/useMetrics.ts
Normal file
24
app/composables/useMetrics.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import type { DeliveryMetrics } from "~/types";
|
||||
|
||||
export function useMetrics() {
|
||||
const { needLogin } = useAuthState();
|
||||
const metrics = ref<DeliveryMetrics | null>(null);
|
||||
const loading = ref(false);
|
||||
const error = ref("");
|
||||
|
||||
async function load(): Promise<void> {
|
||||
loading.value = true;
|
||||
error.value = "";
|
||||
needLogin.value = false;
|
||||
try {
|
||||
const data = await apiFetch<{ metrics?: DeliveryMetrics }>("/admin/api/metrics");
|
||||
metrics.value = data.metrics ?? null;
|
||||
} catch (err) {
|
||||
if (!needLogin.value) error.value = err instanceof Error ? err.message : String(err);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
return { metrics, loading, error, load };
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue