Fixed healthcheck errors
This commit is contained in:
parent
3b4556b9c4
commit
202882aa7c
@ -85,7 +85,7 @@ services:
|
||||
- CatalogUrl=http://catalog.api:5101/hc
|
||||
- OrderingUrl=http://ordering.api:5102/hc
|
||||
- BasketUrl=http://basket.api:5103/hc
|
||||
- IdentityUrl=http://10.0.75.1:5105/hc
|
||||
- IdentityUrl=http://identity.api:5105/hc
|
||||
- mvc=http://webmvc:5100/hc
|
||||
- spa=http://webspa:5104/hc
|
||||
ports:
|
||||
|
@ -40,7 +40,7 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API
|
||||
|
||||
services.AddHealthChecks(checks =>
|
||||
{
|
||||
checks.AddValueTaskCheck("Always OK", () => new ValueTask<IHealthCheckResult>(HealthCheckResult.Healthy("Ok")));
|
||||
checks.AddValueTaskCheck("HTTP Endpoint", () => new ValueTask<IHealthCheckResult>(HealthCheckResult.Healthy("Ok")));
|
||||
});
|
||||
|
||||
// Add framework services.
|
||||
|
@ -48,7 +48,7 @@
|
||||
|
||||
services.AddHealthChecks(checks =>
|
||||
{
|
||||
checks.AddUrlCheck(Configuration["ExternalCatalogBaseUrl"]);
|
||||
checks.AddSqlCheck("CatalogDb", Configuration["ConnectionString"]);
|
||||
});
|
||||
|
||||
services.AddMvc(options =>
|
||||
|
@ -53,7 +53,7 @@
|
||||
|
||||
services.AddHealthChecks(checks =>
|
||||
{
|
||||
checks.AddSqlCheck("Ordering_Db", Configuration["ConnectionString"]);
|
||||
checks.AddSqlCheck("OrderingDb", Configuration["ConnectionString"]);
|
||||
});
|
||||
|
||||
services.AddEntityFrameworkSqlServer()
|
||||
|
@ -48,7 +48,7 @@ namespace Microsoft.eShopOnContainers.WebMVC
|
||||
|
||||
services.AddHealthChecks(checks =>
|
||||
{
|
||||
checks.AddUrlCheck(Configuration["CallBackUrl"]);
|
||||
checks.AddValueTaskCheck("HTTP Endpoint", () => new ValueTask<IHealthCheckResult>(HealthCheckResult.Healthy("Ok")));
|
||||
});
|
||||
|
||||
// Add application services.
|
||||
|
@ -10,6 +10,7 @@ using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using eShopOnContainers.WebSPA;
|
||||
using Microsoft.Extensions.HealthChecks;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace eShopConContainers.WebSPA
|
||||
{
|
||||
@ -42,7 +43,7 @@ namespace eShopConContainers.WebSPA
|
||||
{
|
||||
services.AddHealthChecks(checks =>
|
||||
{
|
||||
checks.AddUrlCheck(Configuration["CallBackUrl"]);
|
||||
checks.AddValueTaskCheck("HTTP Endpoint", () => new ValueTask<IHealthCheckResult>(HealthCheckResult.Healthy("Ok")));
|
||||
});
|
||||
|
||||
services.Configure<AppSettings>(Configuration);
|
||||
|
@ -25,7 +25,7 @@ namespace WebStatus.Controllers
|
||||
|
||||
foreach (var checkResult in result.Results)
|
||||
{
|
||||
data.AddResult(checkResult.Value);
|
||||
data.AddResult(checkResult.Key, checkResult.Value);
|
||||
}
|
||||
|
||||
return View(data);
|
||||
|
@ -9,13 +9,13 @@ namespace WebStatus.Viewmodels
|
||||
public class HealthStatusViewModel
|
||||
{
|
||||
private readonly CheckStatus _overall;
|
||||
private readonly List<IHealthCheckResult> _results;
|
||||
private readonly Dictionary<string, IHealthCheckResult> _results;
|
||||
|
||||
public CheckStatus OverallStatus => _overall;
|
||||
public IEnumerable<IHealthCheckResult> Results => _results;
|
||||
private HealthStatusViewModel() => _results = new List<IHealthCheckResult>();
|
||||
public IEnumerable<NamedCheckResult> Results => _results.Select(kvp => new NamedCheckResult(kvp.Key, kvp.Value));
|
||||
private HealthStatusViewModel() => _results = new Dictionary<string, IHealthCheckResult>();
|
||||
public HealthStatusViewModel(CheckStatus overall) : this() => _overall = overall;
|
||||
public void AddResult(IHealthCheckResult result) => _results.Add(result);
|
||||
public void AddResult(string name, IHealthCheckResult result) => _results.Add(name, result);
|
||||
|
||||
|
||||
}
|
||||
|
20
src/Web/WebStatus/Viewmodels/NamedCheckResult.cs
Normal file
20
src/Web/WebStatus/Viewmodels/NamedCheckResult.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using Microsoft.Extensions.HealthChecks;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WebStatus.Viewmodels
|
||||
{
|
||||
public class NamedCheckResult
|
||||
{
|
||||
public string Name { get; }
|
||||
public IHealthCheckResult Result { get; }
|
||||
|
||||
public NamedCheckResult(string name, IHealthCheckResult result)
|
||||
{
|
||||
Name = name;
|
||||
Result = result;
|
||||
}
|
||||
}
|
||||
}
|
@ -16,26 +16,30 @@
|
||||
{
|
||||
<div class="row list-group-status-item">
|
||||
<div class="col-md-10">
|
||||
<h4 class="list-group-status-item-title">@result.Data["url"]</h4>
|
||||
<p class="list-group-item-text">@result.Description</p>
|
||||
|
||||
<h4 class="list-group-status-item-title">@result.Name</h4>
|
||||
<p class="list-group-item-text">
|
||||
@if (result.Result.Data.ContainsKey("url")) {
|
||||
<p>@result.Result.Data["url"]</p>
|
||||
}
|
||||
@result.Result.Description
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-md-2 list-group-status-item-label">
|
||||
@if (@result.CheckStatus == Microsoft.Extensions.HealthChecks.CheckStatus.Healthy)
|
||||
@if (@result.Result.CheckStatus == Microsoft.Extensions.HealthChecks.CheckStatus.Healthy)
|
||||
{
|
||||
<span class="label label-success">@result.CheckStatus</span>
|
||||
<span class="label label-success">@result.Result.CheckStatus</span>
|
||||
}
|
||||
else if (@result.CheckStatus == Microsoft.Extensions.HealthChecks.CheckStatus.Unhealthy)
|
||||
else if (@result.Result.CheckStatus == Microsoft.Extensions.HealthChecks.CheckStatus.Unhealthy)
|
||||
{
|
||||
<span class="label label-danger">@result.CheckStatus</span>
|
||||
<span class="label label-danger">@result.Result.CheckStatus</span>
|
||||
}
|
||||
else if (@result.CheckStatus == Microsoft.Extensions.HealthChecks.CheckStatus.Warning)
|
||||
else if (@result.Result.CheckStatus == Microsoft.Extensions.HealthChecks.CheckStatus.Warning)
|
||||
{
|
||||
<span class="label label-warning">@result.CheckStatus</span>
|
||||
<span class="label label-warning">@result.Result.CheckStatus</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="label label-default">@result.CheckStatus</span>
|
||||
<span class="label label-default">@result.Result.CheckStatus</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user