branch icon

Too much noise in logs because of healthcheck - prometheus #15177

Description

Resolves #13485

Re-configured the serilog configuration for the environment variables. Prometheus scrape requests will no longer pollute logs in development environment. It is still enabled for non-development environments.

Prometheus scraping is still available, they are not just logged in Development environment: image

Sample log for Staging environment:

2023-09-01 18:34:44.441 -04:00 [INF] Initialized all ABP modules.
2023-09-01 18:34:44.504 -04:00 [INF] Now listening on: https://localhost:44388
2023-09-01 18:34:44.504 -04:00 [INF] Application started. Press Ctrl+C to shut down.
2023-09-01 18:34:44.504 -04:00 [INF] Hosting environment: Staging
2023-09-01 18:34:44.504 -04:00 [INF] Content root path: E:\projects\microservice\7.4.0-rc2\services\identity\src\MyStore.IdentityService.HttpApi.Host
2023-09-01 18:34:44.813 -04:00 [INF] Request starting HTTP/2 GET https://host.docker.internal:44388/metrics - -
2023-09-01 18:34:44.943 -04:00 [INF] Executing endpoint 'Prometheus metrics'
2023-09-01 18:34:44.959 -04:00 [INF] Executed endpoint 'Prometheus metrics'
2023-09-01 18:34:44.962 -04:00 [INF] Request finished HTTP/2 GET https://host.docker.internal:44388/metrics - - - 200 - text/plain;+version=0.0.4;+charset=utf-8 149.2979ms
2023-09-01 18:34:58.766 -04:00 [INF] Request starting HTTP/2 GET https://host.docker.internal:44388/metrics - -
2023-09-01 18:34:58.770 -04:00 [INF] Executing endpoint 'Prometheus metrics'
2023-09-01 18:34:58.776 -04:00 [INF] Executed endpoint 'Prometheus metrics'

Sample log for Development environment:

2023-09-01 18:34:42.611 -04:00 [INF] Initialized all ABP modules.
2023-09-01 18:34:42.713 -04:00 [INF] Now listening on: https://localhost:44367
2023-09-01 18:34:42.713 -04:00 [INF] Application started. Press Ctrl+C to shut down.
2023-09-01 18:34:42.713 -04:00 [INF] Hosting environment: Development
2023-09-01 18:34:42.713 -04:00 [INF] Content root path: E:\projects\microservice\7.4.0-rc2\services\administration\src\MyStore.AdministrationService.HttpApi.Host
2023-09-01 18:34:43.330 -04:00 [INF] Completed to save external localizations.
2023-09-01 18:50:53.784 -04:00 [INF] Executing endpoint 'MyStore.AdministrationService.Controllers.HomeController.Index (MyStore.AdministrationService.HttpApi.Host)'
2023-09-01 18:50:53.798 -04:00 [INF] Route matched with {action = "Index", controller = "Home", area = "", page = ""}. Executing controller action with signature Microsoft.AspNetCore.Mvc.ActionResult Index() on controller MyStore.AdministrationService.Controllers.HomeController (MyStore.AdministrationService.HttpApi.Host).
2023-09-01 18:50:53.814 -04:00 [INF] Executing action method MyStore.AdministrationService.Controllers.HomeController.Index (MyStore.AdministrationService.HttpApi.Host) - Validation state: "Valid"
2023-09-01 18:50:53.816 -04:00 [INF] Executed action method MyStore.AdministrationService.Controllers.HomeController.Index (MyStore.AdministrationService.HttpApi.Host), returned result Microsoft.AspNetCore.Mvc.RedirectResult in 0.1073ms.

Checklist

  • I fully tested it as developer / designer and created unit / integration tests
  • I documented it (or no need to document or I will create a separate documentation issue)

How to test it?

Use different environment for any service in the tye.yaml file to see the logs.

...
env:
    - Kestrel__Certificates__Default__Path=../../../../etc/dev-cert/localhost.pfx
    - Kestrel__Certificates__Default__Password=e8202f07-66e5-4619-be07-72ba76fde97f
    - DOTNET_ENVIRONMENT=Staging
Version
8.0.0-rc.1
发布日期
21 十一月, 2023
标签
feature abp-template-microservice