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