{"id":13610738,"url":"https://github.com/hootsuite/healthchecks","last_synced_at":"2025-10-30T04:41:17.457Z","repository":{"id":57480779,"uuid":"83618799","full_name":"hootsuite/healthchecks","owner":"hootsuite","description":"A go implementation of the Health Checks API used for microservice exploration, documentation and monitoring.","archived":false,"fork":false,"pushed_at":"2019-12-10T17:38:28.000Z","size":38,"stargazers_count":132,"open_issues_count":2,"forks_count":10,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-04-12T00:16:57.310Z","etag":null,"topics":["api","gin-gonic","golang","health","health-checks","microservice","microservices","monitoring"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hootsuite.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}},"created_at":"2017-03-02T01:14:03.000Z","updated_at":"2024-06-22T08:42:35.000Z","dependencies_parsed_at":"2022-09-26T17:41:21.470Z","dependency_job_id":null,"html_url":"https://github.com/hootsuite/healthchecks","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hootsuite%2Fhealthchecks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hootsuite%2Fhealthchecks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hootsuite%2Fhealthchecks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hootsuite%2Fhealthchecks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hootsuite","download_url":"https://codeload.github.com/hootsuite/healthchecks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248497817,"owners_count":21113984,"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":["api","gin-gonic","golang","health","health-checks","microservice","microservices","monitoring"],"created_at":"2024-08-01T19:01:47.537Z","updated_at":"2025-10-30T04:41:12.420Z","avatar_url":"https://github.com/hootsuite.png","language":"Go","funding_links":[],"categories":["Go","monitoring"],"sub_categories":[],"readme":"# go healthchecks\n\n- [Introduction](#introduction)\n- [How to Use It](#how-to-use-it)\n- [Writing a StatusCheck](#writing-a-statuscheck)\n- [Writing a TraverseCheck](#writing-a-traversecheck)\n- [How To Contribute](#how-to-contribute)\n- [License](#license)\n- [Maintainers](#maintainers)\n\n# Introduction\nA go implementation of the [Health Checks API](https://github.com/hootsuite/health-checks-api) used for microservice\nexploration, documentation and monitoring.\n\n# How to Use It\nUsing the `healthchecks` framework in your service is easy.\n- Define a `StatusEndpoint` for each dependency in your service.\n- Register the `healthchecks` framework to respond to all `/status/...` requests passing a slice of all your `StatusEndpoint`s.\n- That's it! As long as you have defined your `StatusEndpoint`s correctly, the framework will take care of the rest.\n\nExample:\n```\n// Define a StatusEndpoint at '/status/db' for a database dependency\ndb := healthchecks.StatusEndpoint{\n  Name: \"The DB\",\n  Slug: \"db\",\n  Type: \"internal\",\n  IsTraversable: false,\n  StatusCheck: sqlsc.SQLDBStatusChecker{\n    DB: myDB\n  },\n  TraverseCheck: nil,\n}\n\n// Define a StatusEndpoint at '/status/service-organization' for the Organization service\norg := healthchecks.StatusEndpoint{\n  Name: \"Organization Service\",\n  Slug: \"service-organization\",\n  Type: \"http\",\n  IsTraversable: true,\n  StatusCheck: httpsc.HttpStatusChecker{\n    BaseUrl: \"[Read value from config]\",\n  },\n  TraverseCheck: httpsc.HttpStatusChecker{\n    BaseUrl: \"[Read value from config]\",\n  },\n}\n\n// Define the list of StatusEndpoints for your service\nstatusEndpoints := []healthchecks.StatusEndpoint{ db, org }\n\n// Set the path for the about and version files\naboutFilePath := \"conf/about.json\"\nversionFilePath := \"conf/version.txt\"\n\n// Set up any service injected customData for /status/about response.\n// Values can be any valid JSON conversion and will override values set in about.json.\ncustomData := make(map[string]interface{})\n// Examples:\n//\n// String value\n// customData[\"a-string\"] = \"some-value\"\n//\n// Number value\n// customData[\"a-number\"] = 123\n//\n// Boolean value\n// customData[\"a-bool\"] = true\n//\n// Array\n// customData[\"an-array\"] = []string{\"val1\", \"val2\"}\n//\n// Custom object\n// customObject := make(map[string]interface{})\n// customObject[\"key1\"] = 1\n// customObject[\"key2\"] = \"some-value\"\n// customData[\"an-object\"] = customObject\n\n// Register all the \"/status/...\" requests to use our health checking framework\nhttp.Handle(\"/status/\", healthchecks.Handler(statusEndpoints, aboutFilePath, versionFilePath, customData))\n```\n\n# Writing a StatusCheck\nA `StatusCheck` is a struct which implements the function `func CheckStatus(name string) StatusList`. A `StatusCheck` is defined or used in\na service but executed by the `healthchecks` framework. The key to a successful `StatusCheck` is to handle all errors on the\ndependency you are checking. Below is an example of a `StatusCheck` that checks the connection of `Redis` using the\n`gopkg.in/redis.v4` driver.\n\n```\ntype RedisStatusChecker struct {\n\tclient RedisClient\n}\n\nfunc (r RedisStatusChecker) CheckStatus(name string) healthchecks.StatusList {\n\tpong, err := r.client.Ping()\n\n\t// Set a default response\n\ts := healthchecks.Status{\n\t\tDescription:  name,\n\t\tResult: healthchecks.OK,\n\t\tDetails: \"\",\n\t}\n\n\t// Handle any errors that Ping() function returned\n\tif err != nil {\n\t\ts = healthchecks.Status{\n\t\t\tDescription:  name,\n\t\t\tResult: healthchecks.CRITICAL,\n\t\t\tDetails: err.Error(),\n\t\t}\n\t}\n\n\t// Make sure the pong response is what we expected\n\tif pong != \"PONG\" {\n\t\ts = healthchecks.Status{\n\t\t\tDescription:  name,\n\t\t\tResult: healthchecks.CRITICAL,\n\t\t\tDetails: fmt.Sprintf(\"Expecting `PONG` response, got `%s`\", pong),\n\t\t}\n\t}\n\n\t// Return our response\n\treturn healthchecks.StatusList{ StatusList: []healthchecks.Status{ s }}\n}\n```\n\n# Writing a TraverseCheck\nA `TraverseCheck` is a struct which implements the function `func Traverse(traversalPath []string, action string) (string, error)`.\nA `TraverseCheck` is defined or used in a service but executed by the `healthchecks` framework. The key to a successful\n`TraverseCheck` is to build and execute the `/status/traverse?action=[action]\u0026dependencies=[dependencies]` request to\nthe service you are trying to traverse to and returning the response or error you got. Below is an example of a\n`TraverseCheck` for an HTTP service.\n\n```\ntype HttpStatusChecker struct {\n\tBaseUrl string\n\tName    string\n}\n\nfunc (h HttpStatusChecker) Traverse(traversalPath []string, action string) (string, error) {\n\tdependencies := \"\"\n\tif len(traversalPath) \u003e 0 {\n\t\tdependencies = fmt.Sprintf(\"\u0026dependencies=%s\", strings.Join(traversalPath, \",\"))\n\t}\n\n\t// Build our HTTP request\n\turl := fmt.Sprintf(\"%s/status/traverse?action=%s%s\", h.BaseUrl, action, dependencies)\n\treq, err := http.NewRequest(\"GET\", url, nil)\n\tif err != nil {\n\t\tfmt.Printf(\"Error creating request: %s \\n\", err.Error())\n\t\treturn \"\", err\n\t}\n\n\t// Execute HTTP request\n\tclient := \u0026http.Client{}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\tfmt.Printf(\"Error executing request: %s \\n\", err.Error())\n\t\treturn \"\", err\n\t}\n\n\t// Defer the closing of the body\n\tdefer resp.Body.Close()\n\n\t// Read our response\n\tresponseBody, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\tfmt.Printf(\"Error reading response body: %s\", err.Error())\n\t\treturn \"\", err\n\t}\n\n\t// Return our response\n\treturn string(responseBody), nil\n}\n```\n\n# How To Contribute\nContribute by submitting a PR and a bug report in GitHub.\n\n# License\nhealthchecks is released under the Apache License, Version 2.0. See [LICENSE](LICENSE) for details.\n\n# Maintainers\n- :octocat: [Adam Arsenault](https://github.com/HootAdam) - [@Adam_Arsenault](https://twitter.com/Adam_Arsenault)\n- :octocat: [Mike Sample](https://github.com/michael-sample-hs) - [@mikesample](https://twitter.com/mikesample)\n- :octocat: [Jim Riecken](https://github.com/jriecken) - [@jimriecken](https://twitter.com/jimriecken)\n- :octocat: [Brandon McRae](https://github.com/brandon-mcrae-hs) - [@HootBrandon](https://twitter.com/HootBrandon)\n- :octocat: [Denis Golovan](https://github.com/denis-golovan-hs) - [@dgolovan](https://twitter.com/dgolovan)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhootsuite%2Fhealthchecks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhootsuite%2Fhealthchecks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhootsuite%2Fhealthchecks/lists"}