MySql health checks package used to check the status of a MySql in ASP.NET Core applications.
LiteXHealthChecks is very small yet powerful and high-performance library used to check the status of a component in the application, such as a backend service, database or some internal state.
Install via Nuget.
PM> Install-Package LiteX.HealthChecks.MySql
{
"Data": {
"ConnectionStrings": {
"MySql": "--REPLACE WITH YOUR CONNECTION STRING--"
}
}
}
public class Startup
{
public IConfiguration Configuration { get; }
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public void ConfigureServices(IServiceCollection services)
{
// 1: Use default configuration
services.AddHealthChecks()
.AddMySql(Configuration["Data:ConnectionStrings:MySql"]);
// OR
// 2: With all optional configuration
services.AddHealthChecks()
.AddMySql(
connectionString: Configuration["Data:ConnectionStrings:MySql"],
name: "mysql",
failureStatus: HealthStatus.Unhealthy,
tags: new string[] { "db", "sql", "mysql" });
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseHealthChecks("/health");
}
}
Sample for other services.
For more helpful information about LiteX HealthChecks, Please click here.