Python prometheus_client.start_http_server() Examples
The following are 9
code examples of prometheus_client.start_http_server().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
prometheus_client
, or try the search function
.
Example #1
Source File: exports.py From django-prometheus with Apache License 2.0 | 6 votes |
def SetupPrometheusEndpointOnPort(port, addr=""): """Exports Prometheus metrics on an HTTPServer running in its own thread. The server runs on the given port and is by default listenning on all interfaces. This HTTPServer is fully independent of Django and its stack. This offers the advantage that even if Django becomes unable to respond, the HTTPServer will continue to function and export metrics. However, this also means that the features offered by Django (like middlewares or WSGI) can't be used. Now here's the really weird part. When Django runs with the auto-reloader enabled (which is the default, you can disable it with `manage.py runserver --noreload`), it forks and executes manage.py twice. That's wasteful but usually OK. It starts being a problem when you try to open a port, like we do. We can detect that we're running under an autoreloader through the presence of the RUN_MAIN environment variable, so we abort if we're trying to export under an autoreloader and trying to open a port. """ assert os.environ.get("RUN_MAIN") != "true", ( "The thread-based exporter can't be safely used when django's " "autoreloader is active. Use the URL exporter, or start django " "with --noreload. See documentation/exports.md." ) prometheus_client.start_http_server(port, addr=addr)
Example #2
Source File: dataexporters.py From ouroboros with MIT License | 6 votes |
def __init__(self, data_manager, config): self.config = config self.data_manager = data_manager self.http_server = prometheus_client.start_http_server( self.config.prometheus_port, addr=self.config.prometheus_addr ) self.updated_containers_counter = prometheus_client.Counter( 'containers_updated', 'Count of containers updated', ['socket', 'container'] ) self.monitored_containers_gauge = prometheus_client.Gauge( 'containers_being_monitored', 'Gauge of containers being monitored', ['socket'] ) self.updated_all_containers_gauge = prometheus_client.Gauge( 'all_containers_updated', 'Count of total updated', ['socket'] ) self.logger = getLogger()
Example #3
Source File: operator.py From anarchy with GNU General Public License v3.0 | 6 votes |
def main(): """Main function.""" init() threading.Thread( name = 'watch_governors', target = watch_governors ).start() threading.Thread( name = 'watch_runners', target = watch_runners ).start() threading.Thread( name = 'watch_runner_pods', target = watch_runner_pods ).start() threading.Thread( name = 'watch_peering', target = watch_peering ).start() threading.Thread( name = 'main', target = main_loop ).start() prometheus_client.start_http_server(8000) http_server = gevent.pywsgi.WSGIServer(('', 5000), api) http_server.serve_forever()
Example #4
Source File: __main__.py From mautrix-telegram with GNU Affero General Public License v3.0 | 6 votes |
def _prepare_website(self, context: Context) -> None: if self.config["appservice.public.enabled"]: public_website = PublicBridgeWebsite(self.loop) self.az.app.add_subapp(self.config["appservice.public.prefix"], public_website.app) context.public_website = public_website if self.config["appservice.provisioning.enabled"]: provisioning_api = ProvisioningAPI(context) self.az.app.add_subapp(self.config["appservice.provisioning.prefix"], provisioning_api.app) context.provisioning_api = provisioning_api if self.config["metrics.enabled"]: if prometheus: prometheus.start_http_server(self.config["metrics.listen_port"]) else: self.log.warning("Metrics are enabled in the config, " "but prometheus_client is not installed.")
Example #5
Source File: kafka_bulk_daemon.py From search-MjoLniR with MIT License | 5 votes |
def main(brokers: str, es_clusters: str, topics: List[str], group_id: str, prometheus_port: int): clusters = make_es_clusters(es_clusters) indices_map_memo = cast(Callable[[], Mapping[str, Elasticsearch]], ttl_memoize(indices_map, clusters=clusters)) def client_for_index(name: str) -> Elasticsearch: return indices_map_memo()[name] prometheus_client.start_http_server(prometheus_port) bulk_daemon.run(brokers, client_for_index, topics, group_id)
Example #6
Source File: msearch_daemon.py From search-MjoLniR with MIT License | 5 votes |
def run(self) -> None: prometheus_client.start_http_server(self.prometheus_port) try: while True: # If we are seeing production traffic do nothing and sit around. self.load_monitor.wait_until_below_threshold() # No production traffic, go ahead and subscribe to kafka self.consume(self.iter_records()) finally: self.producer.close() self.ack_all_producer.close()
Example #7
Source File: prometheus.py From modmail with GNU Affero General Public License v3.0 | 5 votes |
def start(bot): port = 6000 + bot.cluster prom.start_http_server(port) bot.loop.create_task(update_stats(bot)) bot.loop.create_task(update_latency(bot))
Example #8
Source File: core.py From celery-exporter with MIT License | 5 votes |
def _start_httpd(self): # pragma: no cover """ Starts the exposing HTTPD using the addr provided in a separate thread. """ host, port = self._listen_address.split(":") logging.info("Starting HTTPD on {}:{}".format(host, port)) prometheus_client.start_http_server(int(port), host)
Example #9
Source File: celery_prometheus_exporter.py From celery-prometheus-exporter with MIT License | 5 votes |
def start_httpd(addr): # pragma: no cover """ Starts the exposing HTTPD using the addr provided in a separate thread. """ host, port = addr.split(':') logging.info('Starting HTTPD on {}:{}'.format(host, port)) prometheus_client.start_http_server(int(port), host)