Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove 'prog' label from metrics #59

Closed
JamesBarwell opened this issue May 19, 2017 · 9 comments
Closed

Remove 'prog' label from metrics #59

JamesBarwell opened this issue May 19, 2017 · 9 comments
Assignees
Labels
enhancement This is considered a feature request, not currently guaranteed by the code or design today

Comments

@JamesBarwell
Copy link

Hi, when metrics are exported by mtail, I notice that it automatically adds a reference to the mtail program as a label for the metric, e.g.: mymetric{prog="foo.mtail",instance="276d82f2092c"} 1

I was just wondering if it's possible to disable or remove this label via a configuration option. I ask because I am writing a generic exporter and I don't think it's relevant to expose the internals of how my mtail programs are set up to external consumers (or the fact that I am using mtail at all - as great as it is!). In my situation, there is no scenario where a user would want to query by the "progs" label.

Cheers.

@dannyk81
Copy link

You can always drop the label in Prometheus during relabel process, using metrics_relabel_configs.

This way these labels will not be ingested and the end-user will not see them.

There's a great blog about this here

But, in general - this should do the trick:

   metric_relabel_configs:
   - target_label: prog
     replacement: ''

@jaqx0r
Copy link
Contributor

jaqx0r commented May 24, 2017 via email

@JamesBarwell
Copy link
Author

Not sure how complex it would be to implement, but from a user point of view, I'd suggest that conflicting metrics should generate a warn when detected. The second (conflicting) metric - or entire program that it resides in - should be dropped. If this can occur at startup then all the better. Perhaps it can be flagged when using the --one_shot option for testing?

Another thought is whether each program could define and export its own namespace, which would then be prefixed to each metric it writes to. That might make it easier to spot and reject a conflicting namespace. But perhaps that would rather limit how people name their metrics and force them into putting everything into single programs. I've got something similar going on with a library that I wrote for a customer to provide a generic way to monitor their services. The library requires instantiation with a namespace, which is then prefixed on all metrics, logs, notifications, etc.

A config switch would be useful for me, even if it does come with a big caveat!

@dannyk81 Thanks, that is a helpful workaround.

@jaqx0r
Copy link
Contributor

jaqx0r commented May 29, 2017 via email

@jaqx0r
Copy link
Contributor

jaqx0r commented Jun 28, 2017

I'm going to have to do some refactoring in the metric storage, but I am seeing that it is totally necessary (because it's a mess) and will make doing this feature request much easier.

So the only unknown is how do we resolve the namespace problem. I'm happy to drop the prog label entirely but:

if two programs define the same metric name, do they have to have the same type and labelsets?

For type, yes: Prometheus' TYPE annotation is only allowed once per metric. For other collection systems, I don't think they care. I think there's no good coercion rule that allows us to choose either counter or gauge to resolve it automatically.

For labelsets, I think they can be whatever they want, so there could be two metrics with unique, nonintersecting labels that happily sit together with the same name.

@jaqx0r jaqx0r self-assigned this Jun 28, 2017
@jaqx0r jaqx0r added the enhancement This is considered a feature request, not currently guaranteed by the code or design today label Jun 28, 2017
@dannyk81
Copy link

We were hitting a similar issue here -> warmans/prometheus-aggregate-exporter#1

Maybe this can help.

@SuperQ
Copy link
Contributor

SuperQ commented Jul 13, 2017

One thing that is now possible, is that the Prometheus client library supports custom registries. This should make it possible to switch the whole Prometheus endpoint in mtail to the official library. This would also be nice because it exposes some Go internal metrics for monitoring the health of a running mtail instance.

@jaqx0r
Copy link
Contributor

jaqx0r commented Jul 13, 2017 via email

@jaqx0r
Copy link
Contributor

jaqx0r commented Jul 23, 2017

I'm not really happy with implementing this feature, because of the namespacing issue (and that there's a workaround for Prometheus in #59 (comment)) but I've gone and done it anyway. Let's see what technical debt this creates :)

jaqx0r added a commit that referenced this issue Jul 23, 2017
The store add enforces that the first metric added to the store is the
definitive Kind of a metric.  All subsequent metrics added must have that kind,
or the program load fails.

Issue #59
@jaqx0r jaqx0r closed this as completed in a9b6960 Jul 23, 2017
jaqx0r added a commit that referenced this issue Jul 23, 2017
Returns the emission of the prometheus prog label, unless activated by this
flag.  Varz also changes behaviour.  The other push exporters are not modified
as the prog label is intrinsic to their formats (at the moment.)

Fixes #59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This is considered a feature request, not currently guaranteed by the code or design today
Projects
None yet
Development

No branches or pull requests

4 participants