Giter VIP home page Giter VIP logo

health's Issues

Overriding health status string

Hello,

Our internal API guidelines require using the following strings to represent application health status:

  • green
  • orange
  • red

What would be the best way (if any) to use these health statuses instead the ones defined in the library (Healthy, Degraded and Unhealthy)?

Thank you.

InvalidCastException during Db availability check

Hi. I use version 2.0.0 of App.Metrics.Health.Checks.Sql. When I pass to the AddSqlCheck method NpgsqlConnection from the Npgsql.EntityFrameworkCore.PostgreSQL version 2.1.2 package, I get an error in runtime:

"unhealthy": {
"PostgreSQL": "EXCEPTION: InvalidCastException - Unable to cast object of type 'System.Int32' to type 'System.Int64'.\r\n    InvalidCastException: Unable to cast object of type 'System.Int32' to type 'System.Int64'.\r\n    at App.Metrics.Health.Checks.Sql.SqlHealthCheckBuilderExtensions.<>c__DisplayClass0_0.<AddSqlCheck>b__0(CancellationToken cancellationToken) in C:\\projects\\health\\src\\App.Metrics.Health.Checks.Sql\\SqlHealthCheckBuilderExtensions.cs:line 48\r\n"
}

This is most likely due to the fact that ExecuteScalar in NpgsqlCommand returns an int instead of a long.

InvalidCastException when adding sql check

This is the error in health endpoint

{
healthy: {
CPU Health Check: "OK",
Drive Health Check: "OK"
},
unhealthy: {
DB Connection: "EXCEPTION: InvalidCastException - Unable to cast object of type 'System.Int32' to type 'System.Int64'. InvalidCastException: Unable to cast object of type 'System.Int32' to type 'System.Int64'. at App.Metrics.Health.Checks.Sql.SqlHealthCheckBuilderExtensions.<>c__DisplayClass0_0.<AddSqlCheck>b__0(CancellationToken cancellationToken) in C:\projects\health\src\App.Metrics.Health.Checks.Sql\SqlHealthCheckBuilderExtensions.cs:line 48 ",
Private Memory Size: "FAILED. 87666688 > 1000 bytes",
Virtual Memory Size: "FAILED. 2218767613952 > 1000 bytes",
Working Set: "FAILED. 81408000 > 1000"
},
status: "Unhealthy"
}

and the configure for health with deaults :

public static IWebHostBuilder CreateWebHostBuilder(string[] args)
        {
            return WebHost.CreateDefaultBuilder(args)
                .ConfigureHealthWithDefaults(
                builder =>
                {
                    const int threshold = 1000;
                    // Check that the current amount of private memory in bytes is below a threshold
                    builder.HealthChecks.AddProcessPrivateMemorySizeCheck("Private Memory Size", threshold);
                    // Check that the current amount of virtual memory in bytes is below a threshold
                    builder.HealthChecks.AddProcessVirtualMemorySizeCheck("Virtual Memory Size", threshold);
                    // Check that the current amount of physical memory in bytes is below a threshold
                    builder.HealthChecks.AddProcessPhysicalMemoryCheck("Working Set", threshold);

                    // Check db status
                    builder.HealthChecks.AddSqlCheck("DB Connection", () => new SqlConnection("myconnectionstring"), TimeSpan.FromSeconds(10));
                })
                .UseHealth()
                .UseHealthEndpoints()
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseConfiguration(Configuration)
                .UseSerilog()
                .UseIISIntegration()
                .UseKestrel()
                .UseStartup<Startup>();
        }

Manual settable health check result - Possible new feature

Background
For many services the dependencies (sql server, third party web services etc) will frequently be implicitly tested in the normal course of operation. This means that extra explicit checks to those dependencies are redundant.
Proposal
This feature would provide a way for the service code to "manually" update the cached health check result. This result would remain valid for some cache expiry time and would be served out to requests for health checks. So under normal operating conditions we would never have to run the explicit health check. The explicit health check would remain of course as a fall back for the situation where the load on the server is too light to provide a sufficiently frequently updated check.
Implemention
We are happy to implement something and provide a pull request. The design of the HealthCheck class is not extensible but we could implement this feature modifying HealthCheck. By exposing a IManualResultUpdate interface on HealthCheck we would provide access to update the cached result.

Quite time health check

Some failing health checks aren't critical enough to wake up those on on call, but failures are important to alert on during reasonable times.

An example could be the number of messages in a dead letter queue, where it may not be important to alert on a threshold at 2am but would be something that should be investigated and fixed during work hours.

SqlCheck will fail if you pass in an open connection

SqlHealthCheckBuilderExtensions should check that a sql connection is not already open before trying to open it. If you attempt you open an already open DbConnection, it will throw an invalid operation exception.

Access HealthStatus from ASP.NET Core app

I want to report the overall health status to Prometheus. I've understood that in AppMetrics 2.0 it is not done by default anymore. So how can I access that current HealthStatus from an ASP.NET Core app ?
Should I have to call the DefaultHealthCheckRunner ? I would have prefered not to run the health checks myself.

[Question] How to schedule health checks

I am using health checks as part of a Windows Service (using Topshelf). Is there a best practive way of scheduling health checks on a regular basis, e.g. every 5 minutes. It is of course possible to use Quartz or Rx to do something like this but I am just curious to know if there is some build-in way of doing this. I looked in the documentation but did not find anything. Thanks.

PingEndpointEnabled = 'false' is not taken into account

Repro steps:

  1. In appsettings.json specify HealthEndpointOptions with PingEndpointEnabled=false parameter:

"HealthEndpointsOptions": { "HealthEndpointEnabled": true, "PingEndpointEnabled": false, "Timeout": "0:0:10" }

  1. call in Configure method of Startup class

app.UseHealthAllEndpoints();

  1. call in ConfigureServices method of Startup class:

services.AddHealth();
services.AddHealthEndpoints();

Result: [applicationpath]/ping returns 'pong'
Expected result: [applicationpath]/ping returns 404

Problems creating a IReportHealthStatus health reporter, missing CanReport method

I am implementing an IReportHealthStatus health reporter, with the latest health packages 2.1.0-alpha -0118 and when setting up the reporter :

healthReportingBuilder.Using(new HealthNLogReporter());

using the IHealthReporting Builder created by:

AppMetricsHealth.CreateDefaultBuilder()

I get the error:

System.TypeLoadException: Method 'CanReport' in type 'App.Metrics.Health.Builder.HealthBuilder' from assembly 'App.Metrics.Health.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=0d5193a913d1b812' does not have an implementation.
at App.Metrics.Health.AppMetricsHealth.CreateDefaultBuilder()

I assume I must be somehow using the wrong health builder?

Send health status to prometheus

Hi. I use version 2.1.0--alpha-0071. A added services.AddHealthReportingHostedService(). What do i need else to send health status to prometheus. Or version with this feature does not yet released?

Feature suggestion: run health checks in parallel

  1. For now all the health checks discovered during startup are run sequentially. This could cause a problem, when there are many 'heavy' checks configured. E.g. database connection, service availability checks. These two examples are blocking I/O operations which are perfectly parallelilizable.

  2. Also, it would be really nice to have a setting for health check mechanism, which allows to skip all the checks, if at least one of them returned unhealthy.

Reporting of health check results

In earlier versions of App Metrics health and metrics where included in the same package whereby health check results where captured as metrics allowing results to be reported to the underlying TSDB.

In decoupling health and metrics this ability was removed, since there has been several requests to allow for this.

Cache health check

Allow specific health checks to cache their results for a configured period of time

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.