aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2021-12-30 15:10:35 -0600
committermat <github@matdoes.dev>2021-12-30 15:10:35 -0600
commit454a647a8d80e9308e74768e4b48cc6710d2e748 (patch)
treed4a1cc41729c26e78a1d545745d2e879e355c5c1
parentc520324a55d828171f4c2c1e6ebbae74f8560a20 (diff)
downloadskyblock-api-454a647a8d80e9308e74768e4b48cc6710d2e748.tar.gz
skyblock-api-454a647a8d80e9308e74768e4b48cc6710d2e748.tar.bz2
skyblock-api-454a647a8d80e9308e74768e4b48cc6710d2e748.zip
add prom-client
-rw-r--r--package-lock.json46
-rw-r--r--package.json1
-rw-r--r--src/index.ts13
3 files changed, 60 insertions, 0 deletions
diff --git a/package-lock.json b/package-lock.json
index 6933e21..93121d8 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -16,6 +16,7 @@
"node-cache": "^5.1.2",
"node-fetch": "github:tekwiz/node-fetch#fix/chunked-encoding-keepalive",
"prismarine-nbt": "github:PrismarineJS/prismarine-nbt",
+ "prom-client": "^14.0.1",
"queue-promise": "^2.2.1",
"uuid": "^8.3.2"
},
@@ -342,6 +343,11 @@
"node": ">=8"
}
},
+ "node_modules/bintrees": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/bintrees/-/bintrees-1.0.1.tgz",
+ "integrity": "sha1-DmVcm5wkNeqraL9AJyJtK1WjRSQ="
+ },
"node_modules/body-parser": {
"version": "1.19.1",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.1.tgz",
@@ -1518,6 +1524,17 @@
"protodef": "^1.9.0"
}
},
+ "node_modules/prom-client": {
+ "version": "14.0.1",
+ "resolved": "https://registry.npmjs.org/prom-client/-/prom-client-14.0.1.tgz",
+ "integrity": "sha512-HxTArb6fkOntQHoRGvv4qd/BkorjliiuO2uSWC2KC17MUTKYttWdDoXX/vxOhQdkoECEM9BBH0pj2l8G8kev6w==",
+ "dependencies": {
+ "tdigest": "^0.1.1"
+ },
+ "engines": {
+ "node": ">=10"
+ }
+ },
"node_modules/protodef": {
"version": "1.14.0",
"resolved": "https://registry.npmjs.org/protodef/-/protodef-1.14.0.tgz",
@@ -1791,6 +1808,14 @@
"url": "https://github.com/chalk/supports-color?sponsor=1"
}
},
+ "node_modules/tdigest": {
+ "version": "0.1.1",
+ "resolved": "https://registry.npmjs.org/tdigest/-/tdigest-0.1.1.tgz",
+ "integrity": "sha1-Ljyyw56kSeVdHmzZEReszKRYgCE=",
+ "dependencies": {
+ "bintrees": "1.0.1"
+ }
+ },
"node_modules/to-regex-range": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
@@ -2436,6 +2461,11 @@
"integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==",
"dev": true
},
+ "bintrees": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/bintrees/-/bintrees-1.0.1.tgz",
+ "integrity": "sha1-DmVcm5wkNeqraL9AJyJtK1WjRSQ="
+ },
"body-parser": {
"version": "1.19.1",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.1.tgz",
@@ -3280,6 +3310,14 @@
"protodef": "^1.9.0"
}
},
+ "prom-client": {
+ "version": "14.0.1",
+ "resolved": "https://registry.npmjs.org/prom-client/-/prom-client-14.0.1.tgz",
+ "integrity": "sha512-HxTArb6fkOntQHoRGvv4qd/BkorjliiuO2uSWC2KC17MUTKYttWdDoXX/vxOhQdkoECEM9BBH0pj2l8G8kev6w==",
+ "requires": {
+ "tdigest": "^0.1.1"
+ }
+ },
"protodef": {
"version": "1.14.0",
"resolved": "https://registry.npmjs.org/protodef/-/protodef-1.14.0.tgz",
@@ -3481,6 +3519,14 @@
"has-flag": "^4.0.0"
}
},
+ "tdigest": {
+ "version": "0.1.1",
+ "resolved": "https://registry.npmjs.org/tdigest/-/tdigest-0.1.1.tgz",
+ "integrity": "sha1-Ljyyw56kSeVdHmzZEReszKRYgCE=",
+ "requires": {
+ "bintrees": "1.0.1"
+ }
+ },
"to-regex-range": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
diff --git a/package.json b/package.json
index 7fcc238..a919abe 100644
--- a/package.json
+++ b/package.json
@@ -36,6 +36,7 @@
"node-cache": "^5.1.2",
"node-fetch": "github:tekwiz/node-fetch#fix/chunked-encoding-keepalive",
"prismarine-nbt": "github:PrismarineJS/prismarine-nbt",
+ "prom-client": "^14.0.1",
"queue-promise": "^2.2.1",
"uuid": "^8.3.2"
},
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))