64
CHAPTER 3 | Architecting container and microservice-based applications
the event order is challenging. In the same way that you interact with a microservice over agreed-
upon
protocols
and data formats, there’s a need for standardization in how to log health and
diagnostic events that ultimately end up in an event store for querying and viewing. In a microservices
approach, it’s key that different teams agree on a single loggin
g format. There needs to be a
consistent approach to viewing diagnostic events in the application.
Health checks
Health is different from diagnostics. Health is about the microservice reporting its current
state to take
appropriate actions. A good example is working with upgrade and deployment mechanisms to
maintain availability. Although a service might currently be unhealthy due to a process crash or
machine reboot, the service might still be operational. The last thing you need is
to make this worse
by performing an upgrade. The best approach is to do an investigation first or allow time for the
microservice to recover. Health events from a microservice help us make informed decisions and, in
effect, help create self-healing services.
In the
Implementing health checks in ASP.NET Core services
section of this guide, we explain how to
use a new ASP.NET HealthChecks library in your microservices so they can
report their state to a
monitoring service to take appropriate actions.
You also have the option of using an excellent open-source library called
AspNetCore.Diagnostics.HealthChecks, available on
GitHub
and as a
NuGet
package
. This library also
does health checks, with a twist, it handles two types of checks:
•
Dostları ilə paylaş: