{"id":15887833,"url":"https://github.com/yogeshselvarajan/fastapi_cloud_healthcheck","last_synced_at":"2026-01-12T06:41:50.351Z","repository":{"id":257801579,"uuid":"863383242","full_name":"yogeshselvarajan/fastapi_cloud_healthcheck","owner":"yogeshselvarajan","description":"A lightweight and flexible health check package for FastAPI applications, specifically designed for cloud services on AWS and Azure.","archived":false,"fork":false,"pushed_at":"2024-10-03T07:37:31.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-28T05:53:23.103Z","etag":null,"topics":["aws","azure","cloud","fastapi","healthcheck","python"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/fastapi-cloud-healthcheck/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yogeshselvarajan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-26T07:48:50.000Z","updated_at":"2024-10-03T07:37:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"eef0ea06-9f1b-4fd4-9be6-bf88122a655c","html_url":"https://github.com/yogeshselvarajan/fastapi_cloud_healthcheck","commit_stats":null,"previous_names":["yogeshselvarajan/fastapi_cloud_healthcheck"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yogeshselvarajan%2Ffastapi_cloud_healthcheck","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yogeshselvarajan%2Ffastapi_cloud_healthcheck/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yogeshselvarajan%2Ffastapi_cloud_healthcheck/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yogeshselvarajan%2Ffastapi_cloud_healthcheck/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yogeshselvarajan","download_url":"https://codeload.github.com/yogeshselvarajan/fastapi_cloud_healthcheck/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243891970,"owners_count":20364615,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","azure","cloud","fastapi","healthcheck","python"],"created_at":"2024-10-06T06:05:14.076Z","updated_at":"2026-01-12T06:41:50.327Z","avatar_url":"https://github.com/yogeshselvarajan.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fastapi_cloud_healthcheck\n\nA lightweight and flexible health check package for FastAPI applications, specifically designed for cloud services on AWS and Azure. It enables users to implement and expand health checks tailored to their service requirements with ease.\n\nUtilizing Boto3 and Azure SDK for Python, this module allows for custom logic creation for various cloud services, including S3 buckets and Azure Blob storage. While it does not include built-in service checkers, it offers a straightforward framework for users to add their own, ensuring minimal dependency bloat by allowing only necessary packages.\n\n## Installation\nYou can install the package using pip:\n\n```bash\npip install fastapi-cloud-healthcheck\n```\n\n## Getting Started\nHere’s a quick example to get you started with implementing health checks for your FastAPI application:\n\nBefore you start, make sure to install the required package by running:\n```bash\npip install fastapi-cloud-healthcheck-aws-s3bucket\npip install fastapi-cloud-healthcheck-azure-vm\n```\nThen, you can use the following code in your FastAPI application:\n```python\nfrom fastapi import FastAPI\nfrom fastapi_cloud_healthcheck import HealthCheckFactory, create_health_check_route\nfrom fastapi_cloud_healthcheck_aws_s3bucket import HealthCheckS3Bucket\nfrom fastapi_cloud_healthcheck_azure_vm import HealthCheckAzureVM\n\napp = FastAPI()\n\n# Create a factory for health checks\nhealth_check_factory = HealthCheckFactory()\n\n# Adding AWS S3 health check\nhealth_check_factory.add(HealthCheckS3Bucket(\n    bucket_name='my-test-bucket-1232424',\n    region='us-east-1'\n))\n\n# Adding Azure VM Health Check\nhealth_check_factory.add(HealthCheckAzureVM(\n   vm_name=\"SampleTestVM\",\n   resource_group=\"Test-RG\",\n   subscription_id=\"12345678-1234-1234-1234-123456789abc\",\n   region=\"central-india\"\n))\n\n# Adding health check route to the application\napp.add_api_route('/health', endpoint=create_health_check_route(factory=health_check_factory), methods=[\"GET\"])\n\n# Start the FastAPI server using Uvicorn\nif __name__ == \"__main__\":\n    import uvicorn\n    uvicorn.run(\"main:app\", port=5000)\n```\n\n## Health Check Response\nWhen you request a `/health` check, the module evaluates all submitted entries by running basic queries against them. The response will vary depending on the health of the services being checked.\n\n### Success Response\nIf all checks return expected results, the response will include a status code of `200`, indicating a `healthy` state.\n\n```json\n{\n  \"systemHealth\": {\n    \"status\": \"Healthy\",\n    \"description\": \"All services are operating normally.\",\n    \"statusCode\": 200,\n    \"suggestion\": \"No action needed.\"\n  },\n  \"totalResponseTime\": \"0:00:07.661384\",\n  \"lastUpdated\": \"2024-10-03T07:14:02.188021+00:00\",\n  \"summary\": {\n    \"totalServices\": 2,\n    \"healthyServices\": 2,\n    \"unhealthyServices\": 0,\n    \"warningServices\": 0\n  },\n  \"entities\": [\n    {\n      \"identifier\": \"my-test-bucket-1232424\",\n      \"healthStatus\": \"Healthy\",\n      \"statusCode\": 200,\n      \"responseTime\": \"0:00:02.458496\",\n      \"metadata\": {\n        \"provider\": \"aws\",\n        \"region\": \"us-east-1\",\n        \"category\": \"storage\",\n        \"serviceName\": \"S3\",\n        \"accountId\": \"123456789101\" \n      },\n      \"statusMessages\": {\n        \"bucketCheck\": \"Bucket exists and is accessible.\",\n        \"objectUpload\": \"Test object uploaded successfully.\",\n        \"objectRead\": \"Test object content matches.\",\n        \"cleanup\": \"Test object cleaned up successfully.\"\n      }\n    },\n    {\n      \"identifier\": \"SampleTestVM\",\n      \"healthStatus\": \"Healthy\",\n      \"statusCode\": 200,\n      \"responseTime\": \"0:00:05.202888\",\n      \"metadata\": {\n        \"provider\": \"azure\",\n        \"region\": \"central-india\",\n        \"category\": \"compute\",\n        \"serviceName\": \"VM\",\n        \"subscriptionId\": \"12345678-1234-1234-1234-123456789abc\"\n      },\n      \"statusMessages\": {\n        \"powerStateCheck\": \"VM is running.\",\n        \"diskHealthCheck\": \"All disks are healthy.\",\n        \"networkInterfaceCheck\": \"All NICs are healthy.\"\n      }\n    }\n  ]\n}\n```\n### Failure Response\nIf any errors occur during the checks, the response will return a status code of `500`, indicating an `unhealthy` state.\n\n```json\n{\n  \"systemHealth\": {\n    \"status\": \"Unhealthy\",\n    \"description\": \"One or more services are not operating normally.\",\n    \"statusCode\": 500,\n    \"suggestion\": \"Please investigate the issues.\"\n  },\n  \"totalResponseTime\": \"0:00:02.638861\",\n  \"lastUpdated\": \"2024-10-03T07:20:01.254438+00:00\",\n  \"summary\": {\n    \"totalServices\": 2,\n    \"healthyServices\": 1,\n    \"unhealthyServices\": 1,\n    \"warningServices\": 0\n  },\n  \"entities\": [\n    {\n      \"identifier\": \"my-test-bucket-1232424\",\n      \"healthStatus\": \"Healthy\",\n      \"statusCode\": 200,\n      \"responseTime\": \"0:00:02.245721\",\n      \"metadata\": {\n        \"provider\": \"aws\",\n        \"region\": \"us-east-1\",\n        \"category\": \"storage\",\n        \"serviceName\": \"S3\",\n        \"accountId\": \"123456789101\",\n        \"lastChecked\": \"2024-10-03T12:43:45.990525+05:30\"\n      },\n      \"statusMessages\": {\n        \"bucketCheck\": \"Bucket exists and is accessible.\",\n        \"objectUpload\": \"Test object uploaded successfully.\",\n        \"objectRead\": \"Test object content matches.\",\n        \"cleanup\": \"Test object cleaned up successfully.\"\n      }\n    },\n    {\n      \"identifier\": \"SampleTestVM\",\n      \"healthStatus\": \"Unhealthy\",\n      \"statusCode\": 500,\n      \"responseTime\": \"0:00:00.387757\",\n      \"metadata\": {\n        \"provider\": \"azure\",\n        \"region\": \"central-india\",\n        \"category\": \"compute\",\n        \"serviceName\": \"VM\",\n        \"subscriptionId\": \"12345678-1234-1234-1234-123456789abc\"\n      },\n      \"statusMessages\": {\n        \"powerStateCheck\": \"VM is not running.\"\n      }\n    }\n  ]\n}\n```\n\n## Available Modules\nExplore the available health check modules for this framework, designed to help you monitor the health of various services and systems:\n\n* [fastapi_cloud_healthcheck_aws_s3bucket](https://github.com/yogeshselvarajan/fastapi-cloud-healthcheck-aws-s3bucket/blob/01cd0a494649aa0b580c03beaa3aedc24268da8b/fastapi_cloud_healthcheck_aws_s3bucket/bucket_check.py)\n* [fastapi_cloud_healthcheck_azure_vm](https://github.com/yogeshselvarajan/fastapi_cloud_healthcheck_azure_vm/blob/6a6202348ad508ac8213d84eaf4ecb5ca6d619ee/fastapi_cloud_healthcheck_azure_vm/service.py)\n\nIf you've developed a public service module for this framework using any cloud service and would like to have it included in this list, please feel free to open a new issue in the repository. We will review your submission and add it to the list.\n\n## Writing a Custom Module\nYou can easily extend the core health check module to support additional services by creating a custom module. Follow the steps below to build your own health check service:\n\n1. **Implement the Interface**  \n   Create a new service that implements the inherits the [HealthCheckBase](https://github.com/yogeshselvarajan/fastapi_cloud_healthcheck/blob/ac07ad1a6406520b28fd6b44e25daba6335434d5/fastapi_cloud_healthcheck/fastapi_cloud_healthcheck/services/base.py). It provides the necessary structure for integrating your custom health check.\n\n2. **Build the Custom Class**  \n   Design your class around the base class, implementing the required methods to define the health check logic at the ` __checkHealth__` function for your specific service based on the use case.\n\n3. **Add to HealthCheckFactory**  \n   Once your service is ready, integrate it into the `HealthCheckFactory` using the `main` file. This allows your custom health check to be easily used within the existing framework.\n\nFor a more concrete example, refer to the [fastapi_cloud_healthcheck_aws_s3bucket](https://github.com/yogeshselvarajan/fastapi-cloud-healthcheck-aws-s3bucket/blob/01cd0a494649aa0b580c03beaa3aedc24268da8b/fastapi_cloud_healthcheck_aws_s3bucket/bucket_check.py) module. It provides a detailed example of how to create and structure your own service to interface with the FastAPI health check system.\n\n### Contributing\n\nOnce your custom module is ready, feel free to submit it to the repository by opening an issue. Your module could be added to the list of available health check modules.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyogeshselvarajan%2Ffastapi_cloud_healthcheck","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyogeshselvarajan%2Ffastapi_cloud_healthcheck","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyogeshselvarajan%2Ffastapi_cloud_healthcheck/lists"}