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

0 defaults for counters #21

Open
tsloughter opened this issue Aug 15, 2017 · 3 comments
Open

0 defaults for counters #21

tsloughter opened this issue Aug 15, 2017 · 3 comments

Comments

@tsloughter
Copy link
Member

I think the issue I've been dealing with for graphing in grafana and bother @deadtrickster with :) is resolved by metrics like http_requests_failed_total were exported as 0 instead of being left out when they haven't been incremented.

I'll look into how to accomplish this, but opening the issue in case someone knows if this is simply configurable with prometheus.erl or not.

@deadtrickster
Copy link
Member

So prometheus spec mandates label-less metrics to be set to 0 by default. But metrics with labels shouldn't be initialized by prometheus.erl itself. So maybe adding reasonable initialization for known labels makes sense...

https://prometheus.io/docs/practices/instrumentation/#avoid-missing-metrics

@tsloughter
Copy link
Member Author

Do you mean initializing as 0 for known labels like the Reason variable for failed_request?

handle_event(request_closed, _, _) ->
  count_failed_request(request_closed);
handle_event(request_timeout, _, _) ->
  count_failed_request(request_timeout);
handle_event(request_parse_error, _, _) ->
  count_failed_request(request_parse_error);
handle_event(client_closed, [RequestPart], _) ->
  prometheus_counter:inc(?CLIENT_CLOSED_TOTAL, [RequestPart]),
  count_failed_request(client_closed);
handle_event(client_timeout, [RequestPart], _) ->
  prometheus_counter:inc(?CLIENT_TIMEOUT_TOTAL, [RequestPart]),
  count_failed_request(client_timeout);
handle_event(bad_request, [{Reason, _}], _) ->
  prometheus_counter:inc(?BAD_REQUEST_TOTAL, [Reason]),
  count_failed_request(bad_request);

@deadtrickster
Copy link
Member

deadtrickster commented Aug 17, 2017

yes, all these bad_request, client_closed. If cardinality is small that's the way to go. Otherwise you can try or operator.

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

2 participants