core monitoring setup - grecosoft/NetFusion GitHub Wiki
Monitoring: Setup
NetFusion integrates monitoring of a microservice into its defined plug-in architecture. Since a microservice is composed of plug-ins and modules, they provide the ideal location for detecting the overall state of a microservice.
Supported Features
- Health Checks
- Startup Check
- Readiness Check
Adding Monitoring to Microservice
The following assumes the Microservice template, provided by NetFusion, was used to create the initial microservice based solution. Execute the following to create a solution using the template. First, install the template by executing the following:
dotnet new install NetFusion.Templates
Create a directory for the example:
mkdir Examples.Monitoring
Execute the following to generate the solution within the directory:
cd Examples.Monitoring
dotnet new netfusion-microservice -p 5007
cd src/
dotnet build
The solution containing the completed monitoring examples can be found here:
NetFusion-Examples/Examples/Source/Examples.Monitoring
Add NetFusion.Web Nuget Package
Each monitoring type can be exposed as a microservice API endpoint by calling WebApplication extension methods provided within the NetFusion.Web Nuget package.
Run the following to add the NetFusion.Web NuGet to the Examples.Monitoring.Web project:
dotnet add ./src/Examples.Monitoring.WebApi/Examples.Monitoring.WebApi.csproj package NetFusion.Web
Each example will specify the extension method to call for exposing the corresponding monitoring type.
When configuring the endpoints exposed by the service, default values are used for the returned HTTP status codes and the URL used to query each of that statuses. Both of these values can be overridden when calling each of the following methods with parameters:
- app.MapHealthCheck();
- app.MapStartupCheck();
- app.MapReadinessCheck();
app.MapHealthCheck("/state/health", notHealthyStatus: 418);
Running SEQ in Docker
Microservice monitoring details are written to the log. To run the examples locally, the following script can be executed to deploy SEQ to Docker:
cd ./Examples.Monitoring/Docker
docker-compose up -d
When completed, the following can be executed to remove the services running in Docker:
cd ./Examples.Monitoring/Docker
docker-compose down
docker volume rm dev-seq_data
The SEQ log Web interface can be found here: http://localhost:8051/
The example microservice used within the examples can be executed as follows:
cd Examples.Monitoring/src/Examples.Montoring.WebApi/
dotnet run