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

Cannot add custom versions of existing system metrics #155

Closed
msiebuhr opened this issue Aug 4, 2015 · 4 comments
Closed

Cannot add custom versions of existing system metrics #155

msiebuhr opened this issue Aug 4, 2015 · 4 comments

Comments

@msiebuhr
Copy link
Contributor

msiebuhr commented Aug 4, 2015

I'm writing a proxy that ingests Heroku router/runtime metrics logs and converts it to prometheus-ingestable metrics. (See my fork of lumbermill.)

I thought it'd be nice to output metrics in the same form as the ones used elsewhere in Prometheus, ex http_request_size_bytes with the relevant upstream job, instance and endpoint tags. (Though ideally I'd like to include HTTP Method and response code).

Trying to register a handler for this:

httpResponseSizeBytes = prometheus.NewSummaryVec(prometheus.SummaryOpts{
    Name: "http_request_size_bytes",
    Help: "The HTTP response sizes in bytes.",
}, []string {"job", "instance", "handler"})

func init () {
    prometheus.MustRegister(httpResponseSizeBytes)
}

Conflicts with the existing handler for the very same data:

panic: a previously registered descriptor with the same fully-qualified name as Desc{fqName: "http_request_size_bytes", help: "The HTTP request sizes in bytes.", constLabels: {handler="prometheus"}, variableLabels: []} has different label names or a different help string

I've tried unregistering the existing SummaryVec, but to no avail:

func drain(...) {
    prometheus.Unregister(prometheus.NewSummary(prometheus.SummaryOpts{
        Name:        "http_response_size_bytes",
        Help: "The HTTP response sizes in bytes.",
        ConstLabels: prometheus.Labels{"handler": "prometheus"},
    }))
    prometheus.MustRegister(httpResponseSizeBytes)
}

Detects that a handler with a different set of labels has been there previously, and more or less gives me the same panic as above.

@brian-brazil
Copy link
Contributor

I'd argue this is correct behaviour in this case. Exporting the same metric name with different semantics and labels will cause confusion for downstream users, so you should prefix your metrics to separate them.

@fabxc
Copy link
Contributor

fabxc commented Aug 4, 2015

@beorn7 probably can you give the most elaborate answer on this and how this might be affected/resolved by his planned changed to client_golang.

Part of that includes switching the default HTTP handler instrumentation to histograms. So you might want to use histograms instead of summaries right away.

@beorn7
Copy link
Member

beorn7 commented Aug 4, 2015

@msiebuhr I'm working on a client_golang refactoring that will make everything way more easier to configure, but in this particular example, just use UninstrumentedHandler instead of Handler as the handler to register. In that case, no metric will be registered.

@beorn7
Copy link
Member

beorn7 commented Aug 4, 2015

https://github.com/msiebuhr/lumbermill/blob/prometheus/http.go#L51

That's where you need 'UninstrumentedHandler`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants