mirror of
https://github.com/BreizhHardware/express-prom-bundle.git
synced 2026-03-18 21:30:38 +01:00
extend white/black-listing, update readme
This commit is contained in:
@@ -10,7 +10,7 @@ Included metrics:
|
||||
|
||||
* `up`: normally is just 1
|
||||
* `nodejs_memory_heap_total_bytes` and `nodejs_memory_heap_used_bytes`
|
||||
* `http_request_total`: count of http requests labeled with status_code
|
||||
* `http_request_seconds`: http latency histogram labeled with status_code
|
||||
|
||||
## Install
|
||||
|
||||
@@ -29,6 +29,7 @@ const
|
||||
## Options
|
||||
|
||||
* **prefix**: prefix added to every metric name
|
||||
* **whitelist**, **blacklist**: array of strings or regexp. These which metrics to include/exclude
|
||||
|
||||
## Example
|
||||
|
||||
@@ -40,7 +41,8 @@ const express = require("express"),
|
||||
promBundle = require("express-prom-bundle");
|
||||
|
||||
app.use(promBundle({
|
||||
prefix: "demo_app:something"
|
||||
prefix: "demo_app:something",
|
||||
blacklist: ["up"]
|
||||
}));
|
||||
|
||||
app.get("/hello", (req, res) => res.send("ok"));
|
||||
|
||||
@@ -5,10 +5,13 @@ const
|
||||
onFinished = require("on-finished");
|
||||
|
||||
function filterArrayByRegExps(array, regexps) {
|
||||
let compiled = regexps.map(regexp => new RegExp(regexp));
|
||||
return array.filter(element => {
|
||||
for (let regexp of compiled) {
|
||||
if (element.match(regexp)) {
|
||||
for (let regexp of regexps) {
|
||||
if (regexp instanceof RegExp) {
|
||||
if (element.match(regexp)) {
|
||||
return true;
|
||||
}
|
||||
} else if (element == regexp) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user