Skip to content

Healthcheck Endpoint #77

@AEstrellaS

Description

@AEstrellaS

Adding a healthcheck endpoint to keep track of UWAPI's and its dependent backend services statuses.

  • /health :
    • Returns the current health and status of the UWAPI middleware and its dependent backend services.

      UWAPI health fields:

      • status: (String) Always "ok". Indicates that UWAPI is online.
      • http_code: (Integer) Always HTTP 200. Indicates that UWAPI is online.
      • timestamp: (Integer) ISO 8601 UTC timestamp of when the health response was made (e.g., "2025-05-16T20:25:55Z").
      • uptime: (String) Time UWAPI has been running in Xd Yh Zm Ws format.
      • cpu_usage: (String) The percentage of CPU currently used (e.g., "21.2%").
      • memory_usage: (String) The percentage of total system memory used (e.g., "10.1%").
      • process_count: (String) Number of processes currently running on the system.
      • backend_services: (Object) An object describing the status of each backend service UWAPI depends on.

      For each available backend service the following health fields are appended backend_services:

      • status: (String) "ok" if the service responded successfully; "fail" if it did not respond or returned an error.
      • http_code: (Integer) Service health check response HTTP code.
      • latency: (Integer) Present only if the health check succeeded. Round-trip latency in milliseconds to reach the service.

      Below is an example response from /health:

      {
        "backend_services": {
          "gamesmanclassic": {
            "http_code": 200,
            "latency_ms": 109,
            "status": "ok"
          },
          "gamesmanone": {
            "error": "HTTPConnectionPool(host='nyc.cs.berkeley.edu', port=8084): Max retries exceeded with url: /health (Caused by ConnectTimeoutError(\u003Curllib3.connection.HTTPConnection object at 0x106b46c10\u003E, 'Connection to nyc.cs.berkeley.edu timed out. (connect timeout=1.5)'))",
            "status": "fail"
          },
          "gamesmanpuzzles": {
            "http_code": 200,
            "latency_ms": 40,
            "status": "ok"
          }
        },
        "cpu_usage": "6.1%",
        "memory_usage": "58.5%",
        "process_count": 887,
        "status": "ok",
        "timestamp": "2025-05-16T20:47:47Z",
        "uptime": "0d 0h 0m 1s"
      }

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentationenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions