mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
feat: ✨ Implement Prometheus support
This commit is contained in:
parent
26749e576a
commit
f3dd229dcb
15
app.ts
15
app.ts
|
|
@ -4,6 +4,7 @@ import { Hono } from "@hono/hono";
|
||||||
import { cors } from "@hono/hono/cors";
|
import { cors } from "@hono/hono/cors";
|
||||||
import { prettyJSON } from "@hono/hono/pretty-json";
|
import { prettyJSON } from "@hono/hono/pretty-json";
|
||||||
import { secureHeaders } from "@hono/hono/secure-headers";
|
import { secureHeaders } from "@hono/hono/secure-headers";
|
||||||
|
import { prometheus } from "@hono/prometheus";
|
||||||
import { getLogger } from "@logtape/logtape";
|
import { getLogger } from "@logtape/logtape";
|
||||||
import { config } from "~/packages/config-manager/index";
|
import { config } from "~/packages/config-manager/index";
|
||||||
import { agentBans } from "./middlewares/agent-bans";
|
import { agentBans } from "./middlewares/agent-bans";
|
||||||
|
|
@ -22,6 +23,18 @@ export const appFactory = async () => {
|
||||||
strict: false,
|
strict: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { printMetrics, registerMetrics } = prometheus({
|
||||||
|
collectDefaultMetrics: true,
|
||||||
|
metricOptions: {
|
||||||
|
requestsTotal: {
|
||||||
|
customLabels: {
|
||||||
|
content_type: (c) =>
|
||||||
|
c.res.headers.get("content-type") ?? "unknown",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
app.use(ipBans);
|
app.use(ipBans);
|
||||||
app.use(agentBans);
|
app.use(agentBans);
|
||||||
app.use(bait);
|
app.use(bait);
|
||||||
|
|
@ -68,6 +81,8 @@ export const appFactory = async () => {
|
||||||
credentials: true,
|
credentials: true,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
app.use("*", registerMetrics);
|
||||||
|
app.get("/metrics", printMetrics);
|
||||||
// Disabled as federation now checks for this
|
// Disabled as federation now checks for this
|
||||||
// app.use(urlCheck);
|
// app.use(urlCheck);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,7 @@
|
||||||
"@bradenmacdonald/s3-lite-client": "npm:@jsr/bradenmacdonald__s3-lite-client",
|
"@bradenmacdonald/s3-lite-client": "npm:@jsr/bradenmacdonald__s3-lite-client",
|
||||||
"@hackmd/markdown-it-task-lists": "^2.1.4",
|
"@hackmd/markdown-it-task-lists": "^2.1.4",
|
||||||
"@hono/hono": "npm:@jsr/hono__hono@4.5.6",
|
"@hono/hono": "npm:@jsr/hono__hono@4.5.6",
|
||||||
|
"@hono/prometheus": "^1.0.1",
|
||||||
"@hono/zod-validator": "^0.2.2",
|
"@hono/zod-validator": "^0.2.2",
|
||||||
"@inquirer/confirm": "^3.1.22",
|
"@inquirer/confirm": "^3.1.22",
|
||||||
"@inquirer/input": "^2.2.9",
|
"@inquirer/input": "^2.2.9",
|
||||||
|
|
@ -136,6 +137,7 @@
|
||||||
"oauth4webapi": "^2.12.0",
|
"oauth4webapi": "^2.12.0",
|
||||||
"ora": "^8.0.1",
|
"ora": "^8.0.1",
|
||||||
"pg": "^8.12.0",
|
"pg": "^8.12.0",
|
||||||
|
"prom-client": "^15.1.3",
|
||||||
"qs": "^6.13.0",
|
"qs": "^6.13.0",
|
||||||
"sharp": "^0.33.5",
|
"sharp": "^0.33.5",
|
||||||
"sonic-channel": "^1.3.1",
|
"sonic-channel": "^1.3.1",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue