Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⭐ [Enhancement]: New Comprehensive Health Endpoint #2366

Open
JerryNixon opened this issue Sep 6, 2024 · 2 comments
Open

⭐ [Enhancement]: New Comprehensive Health Endpoint #2366

JerryNixon opened this issue Sep 6, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@JerryNixon
Copy link
Contributor

JerryNixon commented Sep 6, 2024

What is it?

  • Adds configuration info to the health endpoint.
  • Includes endpoint basics in the health response.
  • Allows thresholds for response time validation.

Overall Health Calculation

Healthy Unhealthy Global Status
- 0 Healthy
- ≥ 1 Unhealthy
  • Healthy: All checks pass.
  • Unhealthy: At least one check fails.

Standard Health Check Schema

{
  "status": "Healthy",
  "checks": [
    {
      "name": "{name}",
      "status": "Healthy",
      "tags": ["database", "performance"],
      "description": "Checks database query response time.",
      "data": {
        "duration-ms": 50,
        "threshold-ms": 100
      }
    },
    {
      "name": "{name}",
      "status": "Unhealthy",
      "tags": ["database", "performance"],
      "description": "Checks database query response time.",
      "error": "Database connection failed",
      "data": {
        "duration-ms": 150,
        "threshold-ms": 100
      }
    }
  ]
}

Configuration for Data API Builder

Global Health Configuration

{
  "runtime": {
    "health": {
      "enabled": true,
      "cache-ttl": 5,
      "max-dop": 5,
      "roles": ["anonymous", "authenticated"]
    }
  }
}
Property Type Required Default Description
enabled Boolean No true Enables or disables health checks.
cache-ttl Integer No 5 Caches health check results for X seconds.
max-dop Integer No 8 Max parallel health check operations.
roles Array Yes [ ] Defines who can access health checks.

Database-Specific Health Checks

{
  "data-source": {
    "health": {
      "name": "sqlserver",
      "enabled": true,
      "threshold-ms": 100
    }
  }
}
Property Type Required Default Description
name String No NULL Identifier for multi-DB setups.
enabled Boolean No true Enables/disables DB health checks.
query String No N/A Custom SQL for health validation.
threshold-ms Integer No 10000 Max query response time in ms.

Entity-Level Health Checks

{
  "<entity-name>": {
    "health": {
      "enabled": true,
      "first": 1,
      "threshold-ms": 100
    }
  }
}
Property Type Required Default Description
enabled Boolean No true Enables/disables health check for entity.
first Integer No 1 Number of records checked.
threshold-ms Integer No 10000 Max response time before failure.

Example Full Health Check Response

{
  "status": "Unhealthy",
  "version": "1.2.10",
  "app-name": "dab_oss_1.2.10",
  "configuration": {
    "http": true,
    "https": true,
    "rest": true,
    "graphql": true,
    "telemetry": true,
    "caching": true,
    "mode": "development",
    "dab-configs": [
      "/App/dab-config.json (mssql)"
    ],
    "dab-schemas": [
      "/App/schema.json"
    ]
  },
  "checks": [
    {
      "name": "database-moniker",
      "status": "Healthy",
      "tags": ["database", "performance"],
      "description": "Checks if the database is responding within an acceptable timeframe.",
      "data": {
        "duration-ms": 50,
        "threshold-ms": 100
      }
    },
    {
      "name": "database-moniker",
      "status": "Unhealthy",
      "tags": ["database", "performance"],
      "description": "Database response exceeded the threshold.",
      "data": {
        "duration-ms": 150,
        "threshold-ms": 100
      }
    },
    {
      "name": "<entity-name>",
      "status": "Healthy",
      "tags": ["endpoint", "performance"],
      "description": "Checks if the <entity-name> endpoint responds within the threshold.",
      "data": {
        "duration-ms": 50,
        "threshold-ms": 100
      }
    },
    {
      "name": "<entity-name>",
      "status": "Unhealthy",
      "tags": ["endpoint", "performance"],
      "description": "Endpoint exceeded response time threshold.",
      "data": {
        "duration-ms": 150,
        "threshold-ms": 100
      },
      "error": "{exception-message-here}"
    }
  ]
}

Final Notes

status is always at the top level.
checks contains all individual results.
data holds relevant details like duration-ms.

@JerryNixon JerryNixon added the enhancement New feature or request label Sep 6, 2024
@JerryNixon JerryNixon self-assigned this Sep 6, 2024
@seantleonard seantleonard added this to the October2024-March2025 milestone Sep 11, 2024
@JerryNixon JerryNixon pinned this issue Sep 26, 2024
@seantleonard
Copy link
Contributor

Another healthcheck example: DabHealthCheck.cs

internal class DabHealthCheck : IHealthCheck

@JerryNixon JerryNixon unpinned this issue Oct 3, 2024
@aaronpowell
Copy link
Contributor

It looks like https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks has support across the four supported data sources for DAB, would it be easier to add those internally to surface up the health checks, or at least treat them as additive to DAB-specific ones?

Once there is some native health check info surfaced by DAB, I'd love to get it integrated in the .NET Aspire Community Toolkit integration (tracking via CommunityToolkit/Aspire#190).

@abhishekkumams abhishekkumams modified the milestones: 1.4, 1.5 Jan 23, 2025
@sezal98 sezal98 changed the title ⭐ [Enhancement]: Improve Health Endpoint ⭐ [Enhancement]: Comprehensive Health Endpoint (New) Feb 12, 2025
@sezal98 sezal98 changed the title ⭐ [Enhancement]: Comprehensive Health Endpoint (New) ⭐ [Enhancement]: New Comprehensive Health Endpoint Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants