Comments (6)
wouldn't it be a feature of prom-client then? You may want to remove unused labels from other metrics too, not only http_request_duration_seconds
from express-prom-bundle.
From Gauge/Counter/Histogram/Summary classes, I can't easily know which label set has been active or not, how many entries I had, etc. I would need some kind of "labelset-to-timestamp" map to register it right before I "observe" a new value, and this is made inside this module, not prom-client ...
Optional parameters could be how long should it persist and a interval to evaluate this "garbage collector" callback
My case is that I have a huge API made with express, it is hard to keep track of all possible combinations of , there will be always some combinations that happens every once in a while and they will persist forever... on every per-client instance...
from express-prom-bundle.
if you check the code, you'd see it's a very dumb proxy to prom-client. This library has almost zero functionality and of course it doesn't keep any information about your endpoints whatsoever. So this kind of functionality would be in any case out of place here.
On the other hand believe me you're not the only one having a huge API that needs to be monitored. My own solution to this is "path normalization", i.e. before a specific path gets counted it is first transformed into a generic form. E.g. /persons/234234/profile
becomes /persons/#val/profile
. And thus you will have a limited number of combination.
See:
normalizePath: function(req) or Array - if function is provided, then it should generate path value from express req
If the default behavior doesn't work, you may write your own normalizePath in such a way that it's not too much data but also enough for you to identify problematic areas. E.g. instead of conversion above you may turn all /person/*
paths into simply /person
and this way you will know how many requests are about persons in total.
Hope it helps!
from express-prom-bundle.
Well, thanks for the tip about the path normalization. I'm already using it as it is critically necessary.
About the expiration of unused <path,method,status_code>, I convinced myself that this could be resolved from prom-client
. I've changed type from histogram to summary in order to try the "maxAgeSeconds" parameter, but sadly after expiring the observations for a given label set, it is shown as 0 instead of pruning itself.
There is already an issue for it: siimon/prom-client#492
from express-prom-bundle.
With the prom-client fix, and this patch:
diff --git a/src/index.js b/src/index.js
index 0c96dfb9ac0c9e3559b69e83ff60d09f4dcbbd23..8a0aa77516baf65efb8c7f2d3a2b757ad6abcf82 100644
--- a/src/index.js
+++ b/src/index.js
@@ -112,7 +112,8 @@ function main(opts) {
percentiles: opts.percentiles || [0.5, 0.75, 0.95, 0.98, 0.99, 0.999],
maxAgeSeconds: opts.maxAgeSeconds,
ageBuckets: opts.ageBuckets,
- registers: [opts.promRegistry]
+ registers: [opts.promRegistry],
+ pruneAgedBuckets: true,
});
} else if (opts.metricType === 'histogram' || !opts.metricType) {
return new promClient.Histogram({%
Seems to work as expected.
from express-prom-bundle.
FWIW: #119
from express-prom-bundle.
Related Issues (20)
- Missing documentation on combination of autoregister false and metricsApp HOT 2
- Intentional breaking changes? HOT 4
- Option to lowercase all paths HOT 2
- Adding prefix to "up" metric HOT 3
- Add labels to up metric
- @types/express should be marked as a peerDependency
- prom-client 15 compatibility HOT 1
- Unintentional(?) breaking peer dep change in 6.3.1 HOT 1
- Helped needed... HOT 2
- maxAgeSeconds not part of "opts" type HOT 1
- Type definitions do not include promRegistry as a configurable parameter HOT 1
- Package consuming 10gb of virtual memory HOT 5
- Allow a path whitelist option HOT 3
- excludeRoutes is missing from the TypeScript types HOT 1
- Disable http_request_duration_seconds HOT 3
- Cluster: Operation timed out. HOT 2
- Normalizing URL path: Replace #val with custom values/attributes HOT 1
- Missing `promClient` type in the `express_prom_bundle` interface HOT 6
- Disable http_request_duration_seconds_bucket and http_request_duration_seconds_count, but keep http_request_duration_seconds_sum HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from express-prom-bundle.