mirror of
https://github.com/KeyZox71/knl_meowscendence.git
synced 2025-08-16 13:32:53 +02:00
「🏗️」 wip: ELK workingggggggggggggggggggggggggggggggggggg
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
import fastifyJWT from '@fastify/jwt';
|
||||
import fastifyCookie from '@fastify/cookie';
|
||||
import client from 'prom-client';
|
||||
|
||||
import { register } from './register.js';
|
||||
import { login } from './login.js';
|
||||
@ -14,7 +13,6 @@ import { totpVerify } from './totpVerify.js';
|
||||
|
||||
const saltRounds = 10;
|
||||
export const appName = process.env.APP_NAME || 'knl_meowscendence';
|
||||
const collectDefaultMetrics = client.collectDefaultMetrics
|
||||
|
||||
authDB.prepareDB();
|
||||
|
||||
@ -24,29 +22,6 @@ authDB.prepareDB();
|
||||
*/
|
||||
export default async function(fastify, options) {
|
||||
|
||||
collectDefaultMetrics({ labels: { service: "auth-api" } })
|
||||
client.register.setDefaultLabels({ service: "auth-api" })
|
||||
|
||||
const httpRequestCounter = new client.Counter({
|
||||
name: 'http_requests_total',
|
||||
help: 'Total number of HTTP requests',
|
||||
labelNames: ['method', 'route', 'status_code'],
|
||||
})
|
||||
|
||||
fastify.addHook('onResponse', (req, res, done) => {
|
||||
httpRequestCounter.inc({
|
||||
method: req.method,
|
||||
route: req.routerPath || req.url,
|
||||
status_code: res.statusCode,
|
||||
})
|
||||
done()
|
||||
})
|
||||
fastify.get('/metrics', async (req, reply) => {
|
||||
reply
|
||||
.header('Content-Type', client.register.contentType)
|
||||
.send(await client.register.metrics())
|
||||
})
|
||||
|
||||
fastify.register(fastifyJWT, {
|
||||
secret: process.env.JWT_SECRET || '123456789101112131415161718192021',
|
||||
cookie: {
|
||||
|
Reference in New Issue
Block a user