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

refactor: Update the health check UI sample to use SSL #2246

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions samples/HealthChecks.Sample/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:62618/",
"sslPort": 44318
"applicationUrl": "https://localhost:44318",
"useSsl": true
}
},
"profiles": {
Expand All @@ -24,7 +24,8 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:2123/"
"applicationUrl": "https://localhost:44318",
"useSSL": true
}
}
}
14 changes: 8 additions & 6 deletions samples/HealthChecks.Sample/appsettings.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:62618/",
"sslPort": 44318
"applicationUrl": "https://localhost:44318",
"useSsl": true
}
},
"profiles": {
Expand All @@ -24,7 +24,8 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
"applicationUrl": "https://localhost:44318",
"useSSL": true
}
}
}
13 changes: 6 additions & 7 deletions samples/HealthChecks.UI.Branding/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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.
Expand Down
9 changes: 3 additions & 6 deletions samples/HealthChecks.UI.Branding/appsettings.json
Original file line number Diff line number Diff line change
@@ -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": "*"
}
}
7 changes: 4 additions & 3 deletions samples/HealthChecks.UI.Oidc/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:62618/",
"sslPort": 44318
"applicationUrl": "https://localhost:44318",
"useSsl": true
}
},
"profiles": {
Expand All @@ -24,7 +24,8 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
"applicationUrl": "https://localhost:44318",
"useSSL": true
}
}
}
13 changes: 8 additions & 5 deletions samples/HealthChecks.UI.Oidc/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "localhost", /* TODO: CICD should replace this with your environment(dev,test,prod) URLs.*/
"HealthChecksUI": {
"HealthChecks": [
{
Expand All @@ -14,5 +10,12 @@
"Webhooks": [],
"EvaluationTimeinSeconds": 5,
"MinimumSecondsBetweenFailureNotifications": 60
},
"Logging": {
"LogLevel": {
"Default": "Information",
"HealthChecks": "Debug", /* TODO: Not recommended for production environments */
"Microsoft": "Warning"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\HealthChecks.UI.Client\HealthChecks.UI.Client.csproj" />
<ProjectReference Include="..\..\src\HealthChecks.UI.InMemory.Storage\HealthChecks.UI.InMemory.Storage.csproj" />
<ProjectReference Include="..\..\src\HealthChecks.UI\HealthChecks.UI.csproj" />
</ItemGroup>
Expand Down
7 changes: 4 additions & 3 deletions samples/HealthChecks.UI.Sample/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:62618/",
"sslPort": 44318
"applicationUrl": "https://localhost:44318",
"useSsl": true
}
},
"profiles": {
Expand All @@ -24,7 +24,8 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
"applicationUrl": "https://localhost:44318",
"useSSL": true
}
}
}
18 changes: 14 additions & 4 deletions samples/HealthChecks.UI.Sample/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
using HealthChecks.UI.Client;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;

namespace HealthChecks.UI.Sample;

public class Startup
Expand All @@ -6,16 +9,23 @@ 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.
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
});
});
}
}
12 changes: 11 additions & 1 deletion samples/HealthChecks.UI.Sample/appsettings.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand All @@ -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"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:62618/",
"sslPort": 44318
"applicationUrl": "https://localhost:44318",
"useSsl": true
}
},
"profiles": {
Expand All @@ -24,7 +24,8 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
"applicationUrl": "https://localhost:44318",
"useSSL": true
}
}
}
8 changes: 4 additions & 4 deletions samples/HealthChecks.UI.StorageProviders/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"AllowedHosts": "localhost", /* TODO: CICD should replace this with your environment(dev,test,prod) URLs.*/
"HealthChecksUI": {
"HealthChecks": [
{
Expand All @@ -13,9 +14,8 @@
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"HealthChecks": "Debug"
"HealthChecks": "Debug", /* TODO: Not recommended for production environments */
"Microsoft": "Warning"
}
},
"AllowedHosts": "*"
}
}
Loading