Compare commits

..

3 Commits

Author SHA1 Message Date
Félix MARQUET
522e9ad64d bump version to 8.0.1 2025-10-29 12:55:01 +00:00
Félix MARQUET
db8710d5d0 feat: add upMetricName params to allow for up metric name customization 2025-04-25 06:47:26 +00:00
Konstantin Pogorelov
f9a0a7622a bump version to 8.0.0, update express and @types/express to 5 2024-10-12 15:42:42 +02:00
5 changed files with 433 additions and 139 deletions

View File

@@ -55,6 +55,7 @@ Which labels to include in `http_request_duration_seconds` metric:
* **metricsPath**: replace the `/metrics` route with a **regex** or exact **string**. Note: it is highly recommended to just stick to the default
* **metricType**: histogram/summary selection. See more details below
* **httpDurationMetricName**: Allows you change the name of HTTP duration metric, default: **`http_request_duration_seconds`**.
* **upMetricName**: Allows you change the name of up metric, default: **`up`**.
### metricType option ###

561
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "express-prom-bundle",
"version": "7.0.2",
"version": "8.0.1",
"description": "express middleware with popular prometheus metrics in one bundle",
"main": "src/index.js",
"keywords": [
@@ -24,14 +24,14 @@
"author": "Konstantin Pogorelov <or@pluseq.com>",
"license": "MIT",
"dependencies": {
"@types/express": "^4.17.21",
"express": "^4.18.2",
"@types/express": "^5.0.0",
"on-finished": "^2.3.0",
"url-value-parser": "^2.0.0"
},
"devDependencies": {
"dts": "^0.1.1",
"eslint": "^5.11.0",
"express": "^5.0.1",
"istanbul": "^0.4.5",
"jasme": "^6.0.0",
"koa": "^2.6.2",

View File

@@ -91,6 +91,7 @@ function main(opts) {
}
const httpMetricName = opts.httpDurationMetricName || 'http_request_duration_seconds';
const upMetricName = opts.upMetricName || 'up';
function makeHttpMetric() {
const labels = ['status_code'];
@@ -138,7 +139,7 @@ function main(opts) {
prefix = opts.promClient.collectDefaultMetrics.prefix || '';
}
metrics.up = new promClient.Gauge({
name: `${prefix}up`,
name: prefix + upMetricName,
help: '1 = up, 0 = not up',
registers: [opts.promRegistry]
});

1
types/index.d.ts vendored
View File

@@ -38,6 +38,7 @@ declare namespace express_prom_bundle {
metricsPath?: string;
httpDurationMetricName?: string;
upMetricName?: string;
promClient?: { collectDefaultMetrics?: DefaultMetricsCollectorConfiguration<RegistryContentType> };
promRegistry?: Registry;
normalizePath?: NormalizePathEntry[] | NormalizePathFn;