Skip to content

Add health endpoints for monitoring - #91

Open
turegjorup wants to merge 1 commit into
developfrom
feature/health-endpoint
Open

Add health endpoints for monitoring#91
turegjorup wants to merge 1 commit into
developfrom
feature/health-endpoint

Conversation

@turegjorup

@turegjorup turegjorup commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Link to ticket

TODO: no ticket linked yet — please add before review.

Description

Adds /health/live, /health/ready and /health/detail so monitoring can tell whether the application is working, not just responding.

  • /health/live — public, touches nothing. Says only that PHP-FPM is up. A liveness probe that depended on the database would make an orchestrator restart a container that is not at fault.
  • /health/ready — public, but reports the aggregated status only, never which dependency failed. The status code is the payload. Point monitoring at this one.
  • /health/detail — per-check results, messages and timings. Discloses internals, so it sits behind the ITKBasicAuth@file Traefik middleware on its own router, mirroring how /cron-metrics is handled.

Checks are the database, the RabbitMQ messenger transport and detection result freshness. Freshness reads MAX(lastContact) rather than createdAt, because identical submissions are deduplicated by content hash and only bump lastContact — a harvester reporting unchanged servers is still healthy. The RabbitMQ check counts queued messages, which forces a real broker connection and doubles as a backlog signal.

^/health is excluded from the Symfony firewalls rather than protected by one. Both user providers are Doctrine entity providers, so an application-level firewall would fail to authenticate when the database is unavailable and answer 500 instead of reporting it. Authentication belongs at the edge here.

Results are cached in a dedicated, filesystem-backed cache.health pool so polling cannot amplify into load on the dependencies being checked. Filesystem on purpose: the pool has to work when the database and broker do not. Dedicated so the adapter can be swapped in cache.yaml without touching code.

Screenshot of the result

No user interface changes.

Checklist

  • My code is covered by test cases.
  • My code passes our test (all our tests).
  • My code passes our static analysis suite.
  • My code passes our continuous integration process.

Additional comments or questions

HEALTH_INGEST_MAX_AGE defaults to 1800 seconds, based on the harvester's current cadence. Worth a second opinion from whoever knows it best.

A Redis check was written and then dropped. Nothing in the application uses Redis, there is a single phpfpm container, and phpfpm and supervisor already share var/ through the .:/app bind mount. A check that reports skipped forever is noise. Dropping it also let the ext-redis and symfony/cache requirements be reverted, so this branch does not touch composer.json or composer.lock.

Two unrelated follow-ups noticed on the way, both left alone: doctrine.yaml configures a result cache driver that no query enables, and DashboardController.php:59 counts advisories on every admin page load to draw a menu badge.

turegjorup added a commit that referenced this pull request Aug 3, 2026
@turegjorup
turegjorup force-pushed the feature/health-endpoint branch from f17456f to fb9945b Compare August 3, 2026 10:59
Add /health/live, /health/ready and /health/detail, with checks for the
database, the RabbitMQ messenger transport and detection result
freshness.

Liveness touches no dependencies. Readiness reports the aggregated
status only, never which dependency failed. The detailed endpoint
discloses internals and is protected by the ITKBasicAuth Traefik
middleware on its own router.

^/health is excluded from the Symfony firewalls on purpose: both user
providers are Doctrine entity providers, so an application-level
firewall could not authenticate while the database is unavailable.

Results are cached in a dedicated filesystem-backed cache.health pool so
that polling cannot amplify into load on the dependencies being checked.
@turegjorup
turegjorup force-pushed the feature/health-endpoint branch from fb9945b to 613a7d6 Compare August 3, 2026 11:03
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

API Specification - Non-breaking changes

No changelog changes

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 69.60000% with 38 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.98%. Comparing base (bae8493) to head (613a7d6).
⚠️ Report is 14 commits behind head on develop.

Files with missing lines Patch % Lines
src/Health/Check/IngestFreshnessHealthCheck.php 50.00% 14 Missing ⚠️
src/Health/Check/RabbitMqHealthCheck.php 50.00% 8 Missing ⚠️
src/Health/HealthChecker.php 65.21% 8 Missing ⚠️
src/Health/Check/DatabaseHealthCheck.php 60.00% 6 Missing ⚠️
src/Health/HealthCheckResult.php 77.77% 2 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop      #91      +/-   ##
=============================================
+ Coverage      37.14%   38.98%   +1.83%     
- Complexity       948      995      +47     
=============================================
  Files            133      141       +8     
  Lines           2972     3122     +150     
=============================================
+ Hits            1104     1217     +113     
- Misses          1868     1905      +37     
Flag Coverage Δ
unittests 38.98% <69.60%> (+1.83%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants