Title: return httpd.server_address so that ephemeral ports can be surfaced by cwells · Pull Request #574 · prometheus/client_python · GitHub
Open Graph Title: return httpd.server_address so that ephemeral ports can be surfaced by cwells · Pull Request #574 · prometheus/client_python
X Title: return httpd.server_address so that ephemeral ports can be surfaced by cwells · Pull Request #574 · prometheus/client_python
Description: Our platform consists of hundreds of Python agents running on EC2 instances in an ASG that we wish to monitor with Prometheus. The agents will generally be long-running (days, weeks, months), but can be killed or migrated to another node without warning. Because of this, it is not possible to use a fixed port number for exposing the Prometheus endpoint. However, we can pass 0 as the port number and let the OS find an ephemeral port to listen on. Unfortunately there doesn't seem to be a way to surface the resulting port number back to the agent so that we can then populate Consul and let Prometheus know where to scrape data from. This PR addresses this shortcoming. from prometheus_client import start_http_server, Summary import random import time # Create a metric to track time spent and requests made. REQUEST_TIME = Summary('request_processing_seconds', 'Time spent processing request') # Decorate function with metric. @REQUEST_TIME.time() def process_request(t): """A dummy function that takes some time.""" time.sleep(t) if __name__ == '__main__': # Start up the server to expose the metrics. server_address = start_http_server(0) print(server_address) # or send to Consul # Generate some requests. while True: process_request(random.random())
Open Graph Description: Our platform consists of hundreds of Python agents running on EC2 instances in an ASG that we wish to monitor with Prometheus. The agents will generally be long-running (days, weeks, months), but c...
X Description: Our platform consists of hundreds of Python agents running on EC2 instances in an ASG that we wish to monitor with Prometheus. The agents will generally be long-running (days, weeks, months), but c...
Opengraph URL: https://github.com/prometheus/client_python/pull/574
X: @github
Domain: patch-diff.githubusercontent.com
| route-pattern | /:user_id/:repository/pull/:id/checks(.:format) |
| route-controller | pull_requests |
| route-action | checks |
| fetch-nonce | v2:73759d43-15a1-02b5-281e-538527de3a0b |
| current-catalog-service-hash | 87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a |
| request-id | B5C0:5FBC2:2A712F4:360C95E:6991C270 |
| html-safe-nonce | 5fca19171bc9290005891ac37163574b0a1dd2ee26eb676900d2e6f58be2e587 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNUMwOjVGQkMyOjJBNzEyRjQ6MzYwQzk1RTo2OTkxQzI3MCIsInZpc2l0b3JfaWQiOiIyMTE1ODQ3MTY5Nzc2OTI3MzQ0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | cc83387ab5cd66d18c62daa6de1669ee9f0aa9bfe6ee08cbf074cf137463e221 |
| hovercard-subject-tag | pull_request:475057520 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/prometheus/client_python/pull/574/checks |
| twitter:image | https://avatars.githubusercontent.com/u/28466?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/28466?s=400&v=4 |
| og:image:alt | Our platform consists of hundreds of Python agents running on EC2 instances in an ASG that we wish to monitor with Prometheus. The agents will generally be long-running (days, weeks, months), but c... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 42c603b9d642c4a9065a51770f75e5e27132fef0e858607f5c9cb7e422831a7b |
| turbo-cache-control | no-preview |
| go-import | github.com/prometheus/client_python git https://github.com/prometheus/client_python.git |
| octolytics-dimension-user_id | 3380462 |
| octolytics-dimension-user_login | prometheus |
| octolytics-dimension-repository_id | 30618733 |
| octolytics-dimension-repository_nwo | prometheus/client_python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 30618733 |
| octolytics-dimension-repository_network_root_nwo | prometheus/client_python |
| turbo-body-classes | logged-out env-production page-responsive full-width full-width-p-0 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 848bc6032dcc93a9a7301dcc3f379a72ba13b96e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width