@@ -307,7 +328,11 @@ function ServiceMetricsPanel({
minTickGap={32}
tickLine={false}
axisLine={false}
- tickFormatter={(value) => formatCompactDate(value)}
+ tickFormatter={(value) =>
+ !useRangeAwareTimeAxis || rangeLabel === "7d"
+ ? formatCompactDate(value)
+ : formatCompactDateTime(value)
+ }
className="text-xs"
/>
= {
+ "1h": "Last hour",
+ "6h": "Last 6 hours",
+ "24h": "Last 24 hours",
+ "7d": "Last 7 days",
+};
+const MODES: ServiceChartMode[] = [
+ "requests",
+ "latency",
+ "traffic",
+ "resources",
+];
+
+export function ServiceMetricsPage() {
+ const { service } = useService();
+ const [range, setRange] = useQueryState(
+ "range",
+ parseAsStringLiteral(LOG_TIME_RANGES).withDefault("1h"),
+ );
+ const { data, error, isLoading } = useSWR(
+ `/api/services/${service.id}/metrics?range=${range}`,
+ fetcher,
+ { refreshInterval: 60000, keepPreviousData: true },
+ );
+ const hasPublicHttp =
+ service.ports?.some(
+ (port) => port.isPublic && port.domain && port.protocol === "http",
+ ) ?? false;
+
+ return (
+
+
+
+ }>
+ {LABELS[range]}
+
+
+ setRange(value as typeof range)}
+ >
+ {LOG_TIME_RANGES.map((value) => (
+
+ {LABELS[value]}
+
+ ))}
+
+
+
+
+
+ {MODES.map((mode) => (
+
+
+
+ ))}
+
+
+ );
+}
diff --git a/web/components/service/service-layout-client.tsx b/web/components/service/service-layout-client.tsx
index 67fafb1..7d4d0fe 100644
--- a/web/components/service/service-layout-client.tsx
+++ b/web/components/service/service-layout-client.tsx
@@ -130,6 +130,7 @@ export function ServiceLayoutClient({
const basePath = `/dashboard/projects/${projectSlug}/${envName}/services/${service?.id}`;
const isConstrainedTab =
+ pathname.includes("/metrics") ||
pathname.includes("/configuration") ||
pathname.includes("/builds") ||
pathname.includes("/backups");
@@ -139,6 +140,7 @@ export function ServiceLayoutClient({
const tabs = [
{ name: "Deployments", href: basePath },
{ name: "Configuration", href: `${basePath}/configuration` },
+ { name: "Metrics", href: `${basePath}/metrics` },
{ name: "Logs", href: `${basePath}/logs` },
...(hasPublicPorts
? [{ name: "Requests", href: `${basePath}/requests` }]