Closed endofcake closed 7 years ago
Turns out it's possible to specify labels in the push URL:
/metrics/job/<JOBNAME>{/<LABEL_NAME>/<LABEL_VALUE>}
This ties nicely with https://github.com/nexogen-international/Nexogen.Libraries.Metrics/issues/6.
Thanks for the feedback! Let me get back to you with this issue early next week!
This looks like a simple fix, so I can submit a PR if you're willing to accept it.
Thanks! Yes, it is very much appreciated! Submit the PR and we can review & accept it on Monday!
Hi Alexander,
Can't you use it like this?
ILabelledGauge labelledGauge = metrics.Gauge()
.Name("test")
.Help("Test.")
.LabelNames("robot")
.Register();
IGauge wallyGuage = labelledGauge.Labels("WALL-E");
IGauge johnyGauge = labelledGauge.Labels("Johnny-5");
ILabelledGauge is a builder which assigns the label value to the metric and returns a IGauge .
Or do you have something different in mind?
@ahoka , yes, I'm thinking about static labels which do not change during the lifetime of the instance (in our case this is a container running on AWS ECS) and should be applied seamlessly to all metrics. Some examples - AWS region, ECS task version, ECS task id, ECS host instance id. All these values can be grabbed from environment variables, but it's quite tedious to remember to do this for dozens of metrics, would be much better to just set them once. I think using the push URL is a good solution to this, I just need to find time to prepare the PR.
This is roughly what I was thinking about: https://github.com/nexogen-international/Nexogen.Libraries.Metrics/pull/9
The way it works currently is that you define label names statically at metric creation time:
And then you have to specify label values every time you do anything with this metric:
There's no way to set label values once, which is a bit of a pain for things that don't change within the lifetime of a given instance (for example, environment or instance ID).