You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can't find a way (from reading the code and readme) to add labels to the default metrics. This is important with regard to production deployment so that e.g. process id can be associated without forcing this data to be a grouping.
This is particularly important when needing to override the "instance" label (for pushgateway instances)
I agree, as long as we keep the API simple I don't mind this, but I think that will be the hardest part.
I guess you could send in a function that returns an object with key values which is the label key and values. But I guess some validation is needed, since it could only be one level deep and not contain any functions etc..
I also need some kind of such functionality. @siimon probably it could solve the problem if there will be some way to set "default" labels for all metrics. E.g. setting them in some kind of constructor:
But to say the truth I don't like such way, because it's a braking change that could affect a lot of modules. I think there should be easier way to solve this.
At least such approach could be applied to default metrics, after modification of their init function.
I've found some kind of workaround for me. As I use consul for registering my services I was able to add default labels through counsul tags and parse them with promise consul meta information, but anyway if someone don't have such options there should be some way to do this through this lib.
I'm currently in progress of porting all existing metrics into such separate plugins. Also there will be some new plugins like universal http/tcp stats plugin. Some metric names have change, so pay attention to it or just use override option to make them look like current. Also I plan to create some meta package or just helper that could start all those plugins with one or two function calls, but for now they should be started separately.
UPD: Almost all default metrics were ported. Also there's meta-package that installs all of them and provides easy to use API, where you can add labels, override metric names, define regisrty, etc..
Activity
SimenB commentedon Mar 21, 2017
This is not currently possible, no. I like the idea though, but how do you imagine the API would look like? I might give it a crack
siimon commentedon Mar 21, 2017
I agree, as long as we keep the API simple I don't mind this, but I think that will be the hardest part.
I guess you could send in a function that returns an object with key values which is the label key and values. But I guess some validation is needed, since it could only be one level deep and not contain any functions etc..
SkeLLLa commentedon Mar 27, 2017
I also need some kind of such functionality. @siimon probably it could solve the problem if there will be some way to set "default" labels for all metrics. E.g. setting them in some kind of constructor:
and all those labels should be passed to both default metrics constructors and custom. So:
should become:
and custom metrics:
But to say the truth I don't like such way, because it's a braking change that could affect a lot of modules. I think there should be easier way to solve this.
At least such approach could be applied to default metrics, after modification of their init function.
bspradling commentedon Mar 29, 2017
+1 for this request.
SkeLLLa commentedon Mar 29, 2017
I've found some kind of workaround for me. As I use consul for registering my services I was able to add default labels through counsul tags and parse them with promise consul meta information, but anyway if someone don't have such options there should be some way to do this through this lib.
SkeLLLa commentedon May 11, 2017
@goofballLogic, @bspradling8 I've made some "progress" according to this issue. The result you could find here: https://gitlab.com/prometheus-nodejs. There are separate plugins that could be initialized separately (see readmes). During initialization you could override metric name, description, add custom labels or disable some metrics.
I'm currently in progress of porting all existing metrics into such separate plugins. Also there will be some new plugins like universal http/tcp stats plugin. Some metric names have change, so pay attention to it or just use override option to make them look like current. Also I plan to create some meta package or just helper that could start all those plugins with one or two function calls, but for now they should be started separately.
UPD: Almost all default metrics were ported. Also there's meta-package that installs all of them and provides easy to use API, where you can add labels, override metric names, define regisrty, etc..
SimenB commentedon Jul 3, 2017
This is done in #137.
Will be released when #135 lands.