diff --git a/samples/HealthChecks.Sample/Properties/launchSettings.json b/samples/HealthChecks.Sample/Properties/launchSettings.json index 074de8ff97..57df5ae231 100644 --- a/samples/HealthChecks.Sample/Properties/launchSettings.json +++ b/samples/HealthChecks.Sample/Properties/launchSettings.json @@ -4,8 +4,8 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:62618/", - "sslPort": 44318 + "applicationUrl": "https://localhost:44318", + "useSsl": true } }, "profiles": { @@ -24,7 +24,8 @@ "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" }, - "applicationUrl": "http://localhost:2123/" + "applicationUrl": "https://localhost:44318", + "useSSL": true } } } \ No newline at end of file diff --git a/samples/HealthChecks.Sample/appsettings.json b/samples/HealthChecks.Sample/appsettings.json index 6a7858d362..809f4b8a62 100644 --- a/samples/HealthChecks.Sample/appsettings.json +++ b/samples/HealthChecks.Sample/appsettings.json @@ -1,16 +1,18 @@ { + "AllowedHosts": "localhost", /* TODO: CICD should replace this with your environment(dev,test,prod) URLs.*/ "ApplicationInsights": { "InstrumentationKey": "your-instrumentation-key" }, - "Logging": { - "LogLevel": { - "Default": "Warning" - } - }, - "AllowedHosts": "*", "Data": { "ConnectionStrings": { "Sample": "Server=.;Initial Catalog=master;Integrated Security=true" } + }, + "Logging": { + "LogLevel": { + "Default": "Information", + "HealthChecks": "Debug", /* TODO: Not recommended for production environments */ + "Microsoft": "Warning" + } } } diff --git a/samples/HealthChecks.UI.Branding/Properties/launchSettings.json b/samples/HealthChecks.UI.Branding/Properties/launchSettings.json index 3f81a8608a..804abf0bf3 100644 --- a/samples/HealthChecks.UI.Branding/Properties/launchSettings.json +++ b/samples/HealthChecks.UI.Branding/Properties/launchSettings.json @@ -4,8 +4,8 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:62618/", - "sslPort": 44318 + "applicationUrl": "https://localhost:44318", + "useSsl": true } }, "profiles": { @@ -24,7 +24,8 @@ "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" }, - "applicationUrl": "https://localhost:5001;http://localhost:5000" + "applicationUrl": "https://localhost:44318", + "useSSL": true } } } \ No newline at end of file diff --git a/samples/HealthChecks.UI.Branding/Startup.cs b/samples/HealthChecks.UI.Branding/Startup.cs index 4a76026c52..7817097df0 100644 --- a/samples/HealthChecks.UI.Branding/Startup.cs +++ b/samples/HealthChecks.UI.Branding/Startup.cs @@ -25,12 +25,12 @@ public void ConfigureServices(IServiceCollection services) setup.SetHeaderText("Branding Demo - Health Checks Status"); setup.AddHealthCheckEndpoint("endpoint1", "/health-random"); setup.AddHealthCheckEndpoint("endpoint2", "health-process"); - //Webhook endpoint with custom notification hours, and custom failure and description messages + //Webhook endpoint with custom notification hours (8am - 5pm), and custom failure and description messages - setup.AddWebhookNotification("webhook1", uri: "https://healthchecks2.requestcatcher.com/", - payload: "{ message: \"Webhook report for [[LIVENESS]]: [[FAILURE]] - Description: [[DESCRIPTIONS]]\"}", + setup.AddWebhookNotification("webhook2", uri: "https://healthchecks2.requestcatcher.com/", + payload: "{ \"message\": \"Webhook2 report for [[LIVENESS]]: [[FAILURE]] - Description: [[DESCRIPTIONS]]\"}", restorePayload: "{ message: \"[[LIVENESS]] is back to life\"}", - shouldNotifyFunc: (livenessName, report) => DateTime.UtcNow.Hour >= 8 && DateTime.UtcNow.Hour <= 23, + shouldNotifyFunc: (livenessName, report) => DateTime.UtcNow.Hour >= 8 && DateTime.UtcNow.Hour <= 17, customMessageFunc: (livenessName, report) => { var failing = report.Entries.Where(e => e.Value.Status == UIHealthStatus.Unhealthy); @@ -46,11 +46,10 @@ public void ConfigureServices(IServiceCollection services) setup.AddWebhookNotification( name: "webhook1", uri: "https://healthchecks.requestcatcher.com/", - payload: "{ message: \"Webhook report for [[LIVENESS]]: [[FAILURE]] - Description: [[DESCRIPTIONS]]\"}", + payload: "{ \"message\": \"Webhook1 report for [[LIVENESS]]: [[FAILURE]] - Description: [[DESCRIPTIONS]]\"}", restorePayload: "{ message: \"[[LIVENESS]] is back to life\"}"); }).AddInMemoryStorage() - .Services - .AddControllers(); + .Services.AddControllers(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. diff --git a/samples/HealthChecks.UI.Branding/appsettings.json b/samples/HealthChecks.UI.Branding/appsettings.json index 296451c231..6b000be03e 100644 --- a/samples/HealthChecks.UI.Branding/appsettings.json +++ b/samples/HealthChecks.UI.Branding/appsettings.json @@ -1,15 +1,12 @@ { + "AllowedHosts": "localhost", /* TODO: CICD should replace this with your environment(dev,test,prod) URLs.*/ "HealthChecksUI": { - "KubernetesDiscoveryService": { - "Enabled": false - } }, "Logging": { "LogLevel": { "Microsoft": "Warning", - "HealthChecks": "Debug", + "HealthChecks": "Debug", /* TODO: Not recommended for production environments */ "Default": "Information" } - }, - "AllowedHosts": "*" + } } diff --git a/samples/HealthChecks.UI.Oidc/Properties/launchSettings.json b/samples/HealthChecks.UI.Oidc/Properties/launchSettings.json index 3a9031a5a6..4555dfe248 100644 --- a/samples/HealthChecks.UI.Oidc/Properties/launchSettings.json +++ b/samples/HealthChecks.UI.Oidc/Properties/launchSettings.json @@ -4,8 +4,8 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:62618/", - "sslPort": 44318 + "applicationUrl": "https://localhost:44318", + "useSsl": true } }, "profiles": { @@ -24,7 +24,8 @@ "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" }, - "applicationUrl": "https://localhost:5001;http://localhost:5000" + "applicationUrl": "https://localhost:44318", + "useSSL": true } } } \ No newline at end of file diff --git a/samples/HealthChecks.UI.Oidc/appsettings.json b/samples/HealthChecks.UI.Oidc/appsettings.json index 1d585b3813..ee9870cbd6 100644 --- a/samples/HealthChecks.UI.Oidc/appsettings.json +++ b/samples/HealthChecks.UI.Oidc/appsettings.json @@ -1,9 +1,5 @@ { - "Logging": { - "LogLevel": { - "Default": "Warning" - } - }, + "AllowedHosts": "localhost", /* TODO: CICD should replace this with your environment(dev,test,prod) URLs.*/ "HealthChecksUI": { "HealthChecks": [ { @@ -14,5 +10,12 @@ "Webhooks": [], "EvaluationTimeinSeconds": 5, "MinimumSecondsBetweenFailureNotifications": 60 + }, + "Logging": { + "LogLevel": { + "Default": "Information", + "HealthChecks": "Debug", /* TODO: Not recommended for production environments */ + "Microsoft": "Warning" + } } } \ No newline at end of file diff --git a/samples/HealthChecks.UI.Sample/HealthChecks.UI.Sample.csproj b/samples/HealthChecks.UI.Sample/HealthChecks.UI.Sample.csproj index 4d2541e862..1cb1503ec5 100644 --- a/samples/HealthChecks.UI.Sample/HealthChecks.UI.Sample.csproj +++ b/samples/HealthChecks.UI.Sample/HealthChecks.UI.Sample.csproj @@ -10,6 +10,7 @@ + diff --git a/samples/HealthChecks.UI.Sample/Properties/launchSettings.json b/samples/HealthChecks.UI.Sample/Properties/launchSettings.json index 8131355e3b..0962115d74 100644 --- a/samples/HealthChecks.UI.Sample/Properties/launchSettings.json +++ b/samples/HealthChecks.UI.Sample/Properties/launchSettings.json @@ -4,8 +4,8 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:62618/", - "sslPort": 44318 + "applicationUrl": "https://localhost:44318", + "useSsl": true } }, "profiles": { @@ -24,7 +24,8 @@ "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" }, - "applicationUrl": "https://localhost:5001;http://localhost:5000" + "applicationUrl": "https://localhost:44318", + "useSSL": true } } } \ No newline at end of file diff --git a/samples/HealthChecks.UI.Sample/Startup.cs b/samples/HealthChecks.UI.Sample/Startup.cs index 5e240d8fc0..3295c09bd2 100644 --- a/samples/HealthChecks.UI.Sample/Startup.cs +++ b/samples/HealthChecks.UI.Sample/Startup.cs @@ -1,3 +1,6 @@ +using HealthChecks.UI.Client; +using Microsoft.AspNetCore.Diagnostics.HealthChecks; + namespace HealthChecks.UI.Sample; public class Startup @@ -6,9 +9,8 @@ public class Startup // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { - services - .AddHealthChecksUI() - .AddInMemoryStorage(); + services.AddHealthChecks(); + services.AddHealthChecksUI().AddInMemoryStorage(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. @@ -16,6 +18,14 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app .UseRouting() - .UseEndpoints(config => config.MapHealthChecksUI()); + .UseEndpoints(config => + { + config.MapHealthChecksUI(); + config.MapHealthChecks("/healthchecks", new HealthCheckOptions + { + Predicate = _ => true, + ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse + }); + }); } } diff --git a/samples/HealthChecks.UI.Sample/appsettings.json b/samples/HealthChecks.UI.Sample/appsettings.json index 6d3009ce9f..933b520463 100644 --- a/samples/HealthChecks.UI.Sample/appsettings.json +++ b/samples/HealthChecks.UI.Sample/appsettings.json @@ -1,9 +1,11 @@ { + "AllowedHosts": "localhost", /* TODO: CICD should replace this with your environment(dev,test,prod) URLs.*/ "HealthChecksUI": { "HealthChecks": [ { "Name": "HTTP-Api-Basic", - "Uri": "http://localhost:2122/healthz" + "Uri": "https://localhost:44318/healthchecks", + "RequireHttps": true } ], "Webhooks": [ @@ -14,7 +16,15 @@ "RestoredPayload": "{\"text\":\"The HealthCheck [[LIVENESS]] is recovered. All is up and running\",\"channel\":\"#general\",\"link_names\": 1,\"username\":\"monkey-bot\",\"icon_emoji\":\":monkey_face:\"}" } ], + "HeaderText": "The health of my app services", "EvaluationTimeinSeconds": 10, "MinimumSecondsBetweenFailureNotifications": 60 + }, + "Logging": { + "LogLevel": { + "Default": "Information", + "HealthChecks": "Debug", /* TODO: Not recommended for production environments */ + "Microsoft": "Warning" + } } } \ No newline at end of file diff --git a/samples/HealthChecks.UI.StorageProviders/Properties/launchSettings.json b/samples/HealthChecks.UI.StorageProviders/Properties/launchSettings.json index 992924cd01..7a559fb0c9 100644 --- a/samples/HealthChecks.UI.StorageProviders/Properties/launchSettings.json +++ b/samples/HealthChecks.UI.StorageProviders/Properties/launchSettings.json @@ -4,8 +4,8 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:62618/", - "sslPort": 44318 + "applicationUrl": "https://localhost:44318", + "useSsl": true } }, "profiles": { @@ -24,7 +24,8 @@ "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" }, - "applicationUrl": "https://localhost:5001;http://localhost:5000" + "applicationUrl": "https://localhost:44318", + "useSSL": true } } } \ No newline at end of file diff --git a/samples/HealthChecks.UI.StorageProviders/appsettings.json b/samples/HealthChecks.UI.StorageProviders/appsettings.json index cb83f613eb..e7dbb2c79a 100644 --- a/samples/HealthChecks.UI.StorageProviders/appsettings.json +++ b/samples/HealthChecks.UI.StorageProviders/appsettings.json @@ -1,4 +1,5 @@ { + "AllowedHosts": "localhost", /* TODO: CICD should replace this with your environment(dev,test,prod) URLs.*/ "HealthChecksUI": { "HealthChecks": [ { @@ -13,9 +14,8 @@ "Logging": { "LogLevel": { "Default": "Information", - "Microsoft": "Warning", - "HealthChecks": "Debug" + "HealthChecks": "Debug", /* TODO: Not recommended for production environments */ + "Microsoft": "Warning" } - }, - "AllowedHosts": "*" + } }