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

Ability to customize HTTP status codes for Prometheus.Metrics #566

Closed
epaulsen opened this issue Jun 19, 2020 · 3 comments · Fixed by #639
Closed

Ability to customize HTTP status codes for Prometheus.Metrics #566

epaulsen opened this issue Jun 19, 2020 · 3 comments · Fixed by #639

Comments

@epaulsen
Copy link
Contributor

What would you like to be added:
Similar to the healthchecks, I would like to have the ability to map health check results to http status codes for the prometheus metrics publisher.

Why is this needed:
We are currently using the Prometheus health check exporters, and have configured prometheus to scrape /healthmetrics endpoint for all instances at a given interval. This works well as long as health checks are reporting healthy or degraded, we get the metrics for individual health checks.

However, the default behavior whenever a health check reports Unhealthy is to add a http response code of 503 service unavailable. For prometheus, this means that the entire scrape job is aborted, and metrics are not collected for that scrape. This means that we lose fine-grained details about which health check is failing.

I have a fix ready to go if this feature request is ok.

epaulsen pushed a commit to DIPSAS/AspNetCore.Diagnostics.HealthChecks that referenced this issue Jun 19, 2020
…sult and http status codes for HealthChecks.Prometheus.Metrics
@wladneto
Copy link

I need this implemetation... 👍

@CarlosLanderas
Copy link
Contributor

A PR for this feature is welcome. Feel free to contribute ☺️

@CarlosLanderas CarlosLanderas added the Ups for grabs Issue is available to anyone who is interested label Sep 21, 2020
@wladneto
Copy link

I solved with another method...

like this:
app
.UseHealthChecks("/metrics", new HealthCheckOptions
{
ResultStatusCodes =
{
[HealthStatus.Healthy] = StatusCodes.Status200OK,
[HealthStatus.Degraded] = StatusCodes.Status200OK,
[HealthStatus.Unhealthy] = StatusCodes.Status200OK
},
Predicate = _ => true,
ResponseWriter = PrometheusResponseWriter.WritePrometheusResultText
});

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

Successfully merging a pull request may close this issue.

4 participants