{"id":22553393,"url":"https://github.com/faryon93/swarmprom","last_synced_at":"2026-05-10T16:14:56.257Z","repository":{"id":95511142,"uuid":"125671525","full_name":"faryon93/swarmprom","owner":"faryon93","description":"Secure way to expose Prometheus HTTP handler in an Docker Swarm environment.","archived":false,"fork":false,"pushed_at":"2018-05-23T14:02:26.000Z","size":12,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-02T11:13:09.749Z","etag":null,"topics":["docker","go","metric","prometheus","security","swarm"],"latest_commit_sha":null,"homepage":null,"language":"Go","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/faryon93.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":"2018-03-17T21:46:12.000Z","updated_at":"2018-10-10T18:37:27.000Z","dependencies_parsed_at":"2023-04-09T07:43:10.522Z","dependency_job_id":null,"html_url":"https://github.com/faryon93/swarmprom","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faryon93%2Fswarmprom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faryon93%2Fswarmprom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faryon93%2Fswarmprom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faryon93%2Fswarmprom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/faryon93","download_url":"https://codeload.github.com/faryon93/swarmprom/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246010708,"owners_count":20709142,"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":["docker","go","metric","prometheus","security","swarm"],"created_at":"2024-12-07T18:09:23.079Z","updated_at":"2026-05-10T16:14:51.233Z","avatar_url":"https://github.com/faryon93.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# swarmprom\n[![Documentation](https://godoc.org/github.com/faryon93/swarmprom?status.svg)](http://godoc.org/github.com/faryon93/swarmprom)\n[![Go Report Card](https://goreportcard.com/badge/github.com/faryon93/swarmprom)](https://goreportcard.com/report/github.com/faryon93/swarmprom)\n\nThis library provides a secure way to expose the [Prometheus](https://prometheus.io) metrics http handler in a docker swarm environment.\nThe access to the handler is only allowed for containers beloging to the configured swarm service.\nThe relevant ip addresses are obtained from the swarm dns service discovery mechanism.\n\n## Usage\nUse the prometheus primitives to setup your monitoring environment. Just use `swarmprom.Handler()` as the handler for your HTTP server instance.\nAs argument you have to supply the name of the swarm service prometheus is reachable by.\n\n    import (\n        \"github.com/faryon93/swarmprom\"\n        \"github.com/prometheus/client_golang/prometheus\"\n    )\n\n    func main() {\n        // register prometheus metrics\n        var counter = prometheus.NewCounter(prometheus.CounterOpts{\n            Namespace: \"namespace\",\n            Subsystem: \"subsystem\",\n            Name:      \"test_total\",\n            Help:      \"Total number of tests.\",\n        })\n        prometheus.MustRegister(counter)\n\n        // expose http endpoint\n        http.Handle(\"/metrics\", swarmprom.Handler(\"prometheus\"))\n        http.ListenAndServe(\":8080\", nil)\n    }\n\n## Customization\nTo define a custom handler function in case the access get rejected use `swarmprom.SetRejectHandler()`:\n\n    swarmprom.SetRejectHandler(func(w http.ResponseWriter, r *http.Request) {\n        http.Error(w, \"Nice night for a walk!\", http.StatusNotFound)\n    })\n\nTo use a custom logging entry use `swarmprom.SetLogger()`:\n\n    swarmprom.SetLogger(logrus.WithField(\"handler\", \"prometheus\"))","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffaryon93%2Fswarmprom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffaryon93%2Fswarmprom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffaryon93%2Fswarmprom/lists"}