{"id":20303606,"url":"https://github.com/elahe-dastan/http_monitoring","last_synced_at":"2025-03-04T07:12:26.220Z","repository":{"id":113152708,"uuid":"278635560","full_name":"elahe-dastan/HTTP_monitoring","owner":"elahe-dastan","description":"checking the status of URLs periodically","archived":false,"fork":false,"pushed_at":"2020-07-28T20:41:49.000Z","size":8225,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-14T11:14:33.407Z","etag":null,"topics":["golang","http-endpoint","http-monitor","jwt","postgresql","redis"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elahe-dastan.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":"2020-07-10T13:05:21.000Z","updated_at":"2024-02-10T00:08:51.000Z","dependencies_parsed_at":"2023-10-26T18:02:26.099Z","dependency_job_id":null,"html_url":"https://github.com/elahe-dastan/HTTP_monitoring","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elahe-dastan%2FHTTP_monitoring","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elahe-dastan%2FHTTP_monitoring/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elahe-dastan%2FHTTP_monitoring/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elahe-dastan%2FHTTP_monitoring/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elahe-dastan","download_url":"https://codeload.github.com/elahe-dastan/HTTP_monitoring/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241801257,"owners_count":20022389,"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":["golang","http-endpoint","http-monitor","jwt","postgresql","redis"],"created_at":"2024-11-14T16:39:30.242Z","updated_at":"2025-03-04T07:12:26.197Z","avatar_url":"https://github.com/elahe-dastan.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://cloud.drone.io/api/badges/elahe-dastan/HTTP_monitoring/status.svg)](https://cloud.drone.io/elahe-dastan/HTTP_monitoring)\n[![Coverage Status](https://coveralls.io/repos/github/elahe-dastan/HTTP_monitoring/badge.svg?branch=master)](https://coveralls.io/github/elahe-dastan/HTTP_monitoring?branch=master)\n\n# HTTP endpoints monitoring service\nIt's a service with Golang programming language to monitor HTTP endpoints so that in some configurable periods\u003cbr/\u003e\n(e.g., the 30s, 1m, 5m) this service sends HTTP requests to the endpoint and logs the response status code\u003cbr/\u003e\n\n## Endpoints\nTo use this service a user should first register at register endpoint then he should login to get a token at login\u003cbr/\u003e\nendpoint then he can use the token to add url at url endpoint \n\n## Database\nI have used postgres database for this project \n\n## Example of use\n```sh\n$ curl -X POST -d '{\"Email\": \"elahe.dstn@gmail.com\", \"Password\": \"XXXX\"}' \n-H 'Content-Type: application/json' 127.0.0.1:8080/register\n```\n```sh\n$ curl -X POST -d '{\"Email\": \"elahe.dstn@gmail.com\", \"Password\": \"XXXX\"}' \n-H 'Content-Type: application/json' 127.0.0.1:8080/login\n```\nthis should return a token\n\n```sh\n$ curl -X POST -d '{\"URL\": \"https://www.google.com\", \"Period\": 2}' \n-H 'Content-Type: application/json' -H 'Authorization: token' 127.0.0.1:8080/url\n```\n\n## Handling URL Gets\nA period of time is defined for each url to be checked.A goroutine is running and every minute it checks if each URL\u003cbr/\u003e\nshould be gotten or not.The maximum Period is 100 minutes.\n\n## Explanation of the project\nI have a table for users in my postgres database when a user registers at register endpoint I save the user's info in\u003cbr/\u003e\nthe table then a user which has registered before can login and I use JWT to give him a token, he can use the token to \u003cbr/\u003e\nadd urls at the url endpoint the default period is 1 minute and he can specify the period explicitly when posting the\u003cbr/\u003e\nurl.A goroutine is running and each minute gets all the urls, if the period has expired it gets the url and insert the\u003cbr/\u003e\ninformation in redis, each 100 minutes all the data in the redis will be inserted in the status table in the postgres \u003cbr/\u003e\ndatabase and deleted from redis, these statuses will be deleted from database after 2 days.\n\n## System design\n\n![](HTTP_monitoring.png)\n\nAs shown in the image I tried not to have a single point of failure so I have a backup database and I have run two\u003cbr/\u003e \ninstances of the project, there are even two load balancers and the keepalived gives the IP of the working balancer to\u003cbr/\u003e \nanother in case the first one fails to operate.\n\n## Load test\nI used K6 and here is the result:\u003cbr/\u003e\nLoad test on register end point\u003cbr/\u003e\n![](register.png)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felahe-dastan%2Fhttp_monitoring","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felahe-dastan%2Fhttp_monitoring","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felahe-dastan%2Fhttp_monitoring/lists"}