Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
refactor(gateway-pools): rename the load report endpoint to /metrics
bernie-g45625056210b
diff --git a/backend/src/ee/routes/v2/gateway-router.ts b/backend/src/ee/routes/v2/gateway-router.tsindex 08874c04df..ddb7905bcc 100644--- a/backend/src/ee/routes/v2/gateway-router.ts+++ b/backend/src/ee/routes/v2/gateway-router.ts@@ -3,7 +3,7 @@ import z from "zod";import { GatewaysV2Schema } from "@app/db/schemas";import { GATEWAYS } from "@app/lib/api-docs";import { zodBuffer } from "@app/lib/zod";-import { gatewayLoadReportLimit, readLimit, writeLimit } from "@app/server/config/rateLimiter";+import { gatewayMetricsReportLimit, readLimit, writeLimit } from "@app/server/config/rateLimiter";import { slugSchema } from "@app/server/lib/schemas";import { verifyAuth } from "@app/server/plugins/auth/verify-auth";import { AuthMode } from "@app/services/auth/auth-type";@@ -68,25 +68,25 @@ export const registerGatewayV2Router = async (server: FastifyZodProvider) => {// gateway cannot look alive just by reporting load.server.route({method: "POST",- url: "/load",+ url: "/metrics",config: {- rateLimit: gatewayLoadReportLimit+ rateLimit: gatewayMetricsReportLimit},schema: {- operationId: "gatewayLoadReport",+ operationId: "gatewayMetricsReport",body: z.object({- activeChannels: z.number().int().min(0).max(1_000_000).describe(GATEWAYS.LOAD_REPORT.activeChannels)+ activeChannels: z.number().int().min(0).max(1_000_000).describe(GATEWAYS.METRICS_REPORT.activeChannels)}),response: {200: z.object({- gatewayId: z.string().uuid().describe(GATEWAYS.LOAD_REPORT.gatewayId),- activeChannels: z.number().int().describe(GATEWAYS.LOAD_REPORT.activeChannels)+ gatewayId: z.string().uuid().describe(GATEWAYS.METRICS_REPORT.gatewayId),+ activeChannels: z.number().int().describe(GATEWAYS.METRICS_REPORT.activeChannels)})}},onRequest: verifyAuth([AuthMode.IDENTITY_ACCESS_TOKEN, AuthMode.GATEWAY_ACCESS_TOKEN]),handler: async (req) => {- return server.services.gatewayV2.reportLoad({+ return server.services.gatewayV2.reportMetrics({orgPermission: req.permission,activeChannels: req.body.activeChannels});diff --git a/backend/src/ee/services/gateway-v2/gateway-v2-service.ts b/backend/src/ee/services/gateway-v2/gateway-v2-service.tsindex f85ec1e344..aca85d1f8d 100644--- a/backend/src/ee/services/gateway-v2/gateway-v2-service.ts+++ b/backend/src/ee/services/gateway-v2/gateway-v2-service.ts@@ -987,7 +987,7 @@ export const gatewayV2ServiceFactory = ({await $checkGatewayHealth(gateway.id);};- const reportLoad = async ({+ const reportMetrics = async ({orgPermission,activeChannels}: {@@ -1351,7 +1351,7 @@ export const gatewayV2ServiceFactory = ({return {listGateways,registerGateway,- reportLoad,+ reportMetrics,getPlatformConnectionDetailsByGatewayId,getPAMConnectionDetails,deleteGatewayById,diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.tsindex cc1489041b..9c1c394542 100644--- a/backend/src/lib/api-docs/constants.ts+++ b/backend/src/lib/api-docs/constants.ts@@ -3857,7 +3857,7 @@ export const SECRET_SHARING = {} as const;export const GATEWAYS = {- LOAD_REPORT: {+ METRICS_REPORT: {activeChannels:"Number of channels the gateway is currently serving. Used to route new work to the least busy member of a gateway pool.",gatewayId: "ID of the gateway the report was recorded against."diff --git a/backend/src/server/config/rateLimiter.ts b/backend/src/server/config/rateLimiter.tsindex e028cd6346..8331a6a92a 100644--- a/backend/src/server/config/rateLimiter.ts+++ b/backend/src/server/config/rateLimiter.ts@@ -43,13 +43,13 @@ export const writeLimit: RateLimitOptions = {// rather than by IP, because the write limiter's IP key is shared: ~100 gateways behind one NAT// address would exhaust a 200/min quota on load reports alone, start getting 429s, and their// entries would go stale.-export const gatewayLoadReportLimit: RateLimitOptions = {+export const gatewayMetricsReportLimit: RateLimitOptions = {timeWindow: 60 * 1000,hook: "preValidation",max: 10,keyGenerator: (req) => {const actorId = (req as { permission?: { id?: string } }).permission?.id;- return actorId ? `gateway-load:${actorId}` : req.realIp;+ return actorId ? `gateway-metrics:${actorId}` : req.realIp;}};