refactor: Upgrade Prometheus metrics lib to latest version

This commit is contained in:
Göran Sander
2022-07-11 08:46:02 +00:00
parent 496f4ec88c
commit 61d363a80e
5 changed files with 36 additions and 26 deletions

9
.vscode/launch.json vendored
View File

@@ -6,11 +6,18 @@
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/src/butler-sos.js",
"runtimeVersion": "18",
"cwd": "${workspaceFolder}/src",
"env": {
"NODE_CONFIG_DIR": "${workspaceFolder}/src/config",
"NODE_ENV": "production"
},
"args": ["--loglevel", "debug"]
// "args": [
// "--loglevel",
// "info",
// "--configfile",
// "./config/production.yaml"
// ]
}
]
}

37
package-lock.json generated
View File

@@ -20,7 +20,7 @@
"eslint-plugin-prettier": "^4.2.1",
"fastify": "^4.2.0",
"fastify-healthcheck": "^4.0.0",
"fastify-metrics": "^8.0.0",
"fastify-metrics": "^9.0.0",
"fs-extra": "^10.1.0",
"influx": "^5.9.3",
"js-yaml": "^4.1.0",
@@ -1424,18 +1424,21 @@
}
},
"node_modules/fastify-metrics": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/fastify-metrics/-/fastify-metrics-8.0.0.tgz",
"integrity": "sha512-k0J1cm7gYyidzJMg5g9eIMaq7Bx2nj0yNXtMjnVsIuyctrrONzDBabWOgTG489bXE9a2fZ9xKkaHR0zti1SddA==",
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/fastify-metrics/-/fastify-metrics-9.0.0.tgz",
"integrity": "sha512-mIkN3NTXz77WQW7/42sKbOVhIswQRXB6mZ2MO8Q5RiOlivjuxDPJUJSG1fjtQedXvKPHLN6KGYPTYck5ahLCgw==",
"dependencies": {
"fastify-plugin": "^3.0.0",
"prom-client": "^14.0.0"
"fastify-plugin": "^3.0.1",
"prom-client": "^14.0.1"
},
"peerDependencies": {
"fastify": "^4.0.0"
}
},
"node_modules/fastify-plugin": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/fastify-plugin/-/fastify-plugin-3.0.0.tgz",
"integrity": "sha512-ZdCvKEEd92DNLps5n0v231Bha8bkz1DjnPP/aEz37rz/q42Z5JVLmgnqR4DYuNn3NXAO3IDCPyRvgvxtJ4Ym4w=="
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/fastify-plugin/-/fastify-plugin-3.0.1.tgz",
"integrity": "sha512-qKcDXmuZadJqdTm6vlCqioEbyewF60b/0LOFCcYN1B6BIZGlYJumWWOYs70SFYLDAH4YqdE1cxH/RKMG7rFxgA=="
},
"node_modules/fastq": {
"version": "1.13.0",
@@ -4601,18 +4604,18 @@
}
},
"fastify-metrics": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/fastify-metrics/-/fastify-metrics-8.0.0.tgz",
"integrity": "sha512-k0J1cm7gYyidzJMg5g9eIMaq7Bx2nj0yNXtMjnVsIuyctrrONzDBabWOgTG489bXE9a2fZ9xKkaHR0zti1SddA==",
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/fastify-metrics/-/fastify-metrics-9.0.0.tgz",
"integrity": "sha512-mIkN3NTXz77WQW7/42sKbOVhIswQRXB6mZ2MO8Q5RiOlivjuxDPJUJSG1fjtQedXvKPHLN6KGYPTYck5ahLCgw==",
"requires": {
"fastify-plugin": "^3.0.0",
"prom-client": "^14.0.0"
"fastify-plugin": "^3.0.1",
"prom-client": "^14.0.1"
}
},
"fastify-plugin": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/fastify-plugin/-/fastify-plugin-3.0.0.tgz",
"integrity": "sha512-ZdCvKEEd92DNLps5n0v231Bha8bkz1DjnPP/aEz37rz/q42Z5JVLmgnqR4DYuNn3NXAO3IDCPyRvgvxtJ4Ym4w=="
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/fastify-plugin/-/fastify-plugin-3.0.1.tgz",
"integrity": "sha512-qKcDXmuZadJqdTm6vlCqioEbyewF60b/0LOFCcYN1B6BIZGlYJumWWOYs70SFYLDAH4YqdE1cxH/RKMG7rFxgA=="
},
"fastq": {
"version": "1.13.0",

View File

@@ -40,7 +40,7 @@
"eslint-plugin-prettier": "^4.2.1",
"fastify": "^4.2.0",
"fastify-healthcheck": "^4.0.0",
"fastify-metrics": "^8.0.0",
"fastify-metrics": "^9.0.0",
"fs-extra": "^10.1.0",
"influx": "^5.9.3",
"js-yaml": "^4.1.0",

View File

@@ -1,14 +1,14 @@
// Add dependencies
const path = require('path');
const Fastify = require('fastify');
const FastifyHealthcheck = require('fastify-healthcheck');
const Fastify = require('fastify');
const promServer = require('fastify')({ logger: false });
const promFastifyMetricsServer = require('fastify')({ logger: false });
const metricsPlugin = require('fastify-metrics');
const promServer = Fastify({ logger: false });
const promFastifyMetricsServer = Fastify({ logger: false });
const dockerHealthCheckServer = Fastify({ logger: false });
const metricsPlugin = require('fastify-metrics');
promServer.server.keepAliveTimeout = 0;
promFastifyMetricsServer.register(metricsPlugin, { endpoint: '/metrics' });
@@ -205,7 +205,7 @@ async function mainScript() {
try {
// Set up Node.js internal metrics
await promFastifyMetricsServer.listen(promNodePort, promNodeHost);
await promFastifyMetricsServer.listen({ port: promNodePort, host: promNodeHost });
globals.logger.info(
`PROM: Prometheus Node.js metrics server now listening on port ${promNodeHost}:${promNodePort}`
);

View File

@@ -200,7 +200,7 @@ async function setupPromClient(promServer, promPort, promHost) {
}
});
await promServer.listen(promPort, promHost);
await promServer.listen({ port: promPort, host: promHost });
globals.logger.info(
`PROM: Prometheus Butler SOS metrics server now listening on port ${promPort}`
);