From 9d1632ce209b61e6ead17069e3b96b9af74877ef Mon Sep 17 00:00:00 2001 From: eternal-flame-AD Date: Sat, 30 Nov 2024 20:59:17 -0600 Subject: [PATCH] reduce metric cardinaility Signed-off-by: eternal-flame-AD --- packages/backend/src/server/ServerService.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/packages/backend/src/server/ServerService.ts b/packages/backend/src/server/ServerService.ts index 8c3d6b5b27..818efd8740 100644 --- a/packages/backend/src/server/ServerService.ts +++ b/packages/backend/src/server/ServerService.ts @@ -57,7 +57,7 @@ function categorizeRequestPath(path: string): 'api' | 'health' | 'vite' | 'other const mRequestTime = metricHistogram({ name: 'misskey_http_request_duration_seconds', help: 'Duration of handling HTTP requests in seconds', - labelNames: ['host', 'cate', 'method', 'path'], + labelNames: ['cate', 'method', 'path'], buckets: [0.001, 0.1, 0.5, 1, 2, 5], }); @@ -88,19 +88,19 @@ const mTooManyRequestsServed = metricCounter({ const mAggregateRequestsServed = metricCounter({ name: 'misskey_http_requests_served_total', help: 'Total number of HTTP requests served including invalid requests', - labelNames: ['host', 'cate', 'status'], + labelNames: ['cate', 'status'], }); const mRequestsServedByPath = metricCounter({ name: 'misskey_http_requests_served_by_path', help: 'Total number of HTTP requests served', - labelNames: ['host', 'cate', 'method', 'path', 'status'], + labelNames: ['cate', 'method', 'path', 'status'], }); const mFatalErrorCount = metricCounter({ name: 'misskey_fatal_http_errors_total', help: 'Total number of HTTP errors that propagate to the top level', - labelNames: ['host', 'cate', 'method', 'path'], + labelNames: ['cate', 'method', 'path'], }); const mLastSuccessfulRequest = metricGauge({ @@ -172,7 +172,6 @@ export class ServerService implements OnApplicationShutdown { const url = new URL(request.url, this.config.url); const logPath = sanitizeRequestURI(url.pathname); mFatalErrorCount?.inc({ - host: request.hostname, method: request.method, path: logPath, cate: categorizeRequestPath(logPath), @@ -187,7 +186,6 @@ export class ServerService implements OnApplicationShutdown { const received = reply.getHeader('x-request-received') as string; mAggregateRequestsServed?.inc({ - host: request.hostname, cate, status: reply.statusCode, }); @@ -211,7 +209,6 @@ export class ServerService implements OnApplicationShutdown { if (received) { const duration = (+new Date()) - parseInt(received); mRequestTime?.observe({ - host: request.hostname, method: request.method, cate, }, duration / 1000); @@ -234,7 +231,6 @@ export class ServerService implements OnApplicationShutdown { const duration = (+new Date()) - parseInt(received); mRequestTime?.observe({ - host: request.hostname, method: request.method, cate, path: logPath, @@ -253,7 +249,6 @@ export class ServerService implements OnApplicationShutdown { } mRequestsServedByPath?.inc({ - host: request.hostname, method: request.method, path: logPath, cate,