diff options
author | mat <github@matdoes.dev> | 2021-12-30 15:10:35 -0600 |
---|---|---|
committer | mat <github@matdoes.dev> | 2021-12-30 15:10:35 -0600 |
commit | 454a647a8d80e9308e74768e4b48cc6710d2e748 (patch) | |
tree | d4a1cc41729c26e78a1d545745d2e879e355c5c1 /src | |
parent | c520324a55d828171f4c2c1e6ebbae74f8560a20 (diff) | |
download | skyblock-api-454a647a8d80e9308e74768e4b48cc6710d2e748.tar.gz skyblock-api-454a647a8d80e9308e74768e4b48cc6710d2e748.tar.bz2 skyblock-api-454a647a8d80e9308e74768e4b48cc6710d2e748.zip |
add prom-client
Diffstat (limited to 'src')
-rw-r--r-- | src/index.ts | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/index.ts b/src/index.ts index d0e4fd8..ffa683e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,6 +6,7 @@ import * as discord from './discord.js' import express from 'express' import { getKeyUsage } from './hypixelApi.js' import { basicPlayerCache, basicProfilesCache, playerCache, profileCache, profileNameCache, profilesCache, usernameCache } from './hypixelCached.js' +import { collectDefaultMetrics, register } from 'prom-client' const app = express() @@ -185,6 +186,18 @@ app.post('/accounts/update', async (req, res) => { } }) + +// grafana integration +collectDefaultMetrics() +app.get('/metrics', async (_req, res) => { + try { + res.set('Content-Type', register.contentType) + res.end(await register.metrics()) + } catch (err) { + res.status(500).end(err) + } +}) + process.on('uncaughtException', err => console.error(err)) process.on('unhandledRejection', (err, promise) => console.error(promise, err)) |