當前位置: 首頁>>代碼示例>>Python>>正文


Python prometheus_client.start_http_server方法代碼示例

本文整理匯總了Python中prometheus_client.start_http_server方法的典型用法代碼示例。如果您正苦於以下問題:Python prometheus_client.start_http_server方法的具體用法?Python prometheus_client.start_http_server怎麽用?Python prometheus_client.start_http_server使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在prometheus_client的用法示例。


在下文中一共展示了prometheus_client.start_http_server方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: SetupPrometheusEndpointOnPort

# 需要導入模塊: import prometheus_client [as 別名]
# 或者: from prometheus_client import start_http_server [as 別名]
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) 
開發者ID:korfuri,項目名稱:django-prometheus,代碼行數:27,代碼來源:exports.py

示例2: __init__

# 需要導入模塊: import prometheus_client [as 別名]
# 或者: from prometheus_client import start_http_server [as 別名]
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() 
開發者ID:pyouroboros,項目名稱:ouroboros,代碼行數:25,代碼來源:dataexporters.py

示例3: main

# 需要導入模塊: import prometheus_client [as 別名]
# 或者: from prometheus_client import start_http_server [as 別名]
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() 
開發者ID:redhat-cop,項目名稱:anarchy,代碼行數:34,代碼來源:operator.py

示例4: _prepare_website

# 需要導入模塊: import prometheus_client [as 別名]
# 或者: from prometheus_client import start_http_server [as 別名]
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.") 
開發者ID:tulir,項目名稱:mautrix-telegram,代碼行數:20,代碼來源:__main__.py

示例5: main

# 需要導入模塊: import prometheus_client [as 別名]
# 或者: from prometheus_client import start_http_server [as 別名]
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) 
開發者ID:wikimedia,項目名稱:search-MjoLniR,代碼行數:11,代碼來源:kafka_bulk_daemon.py

示例6: run

# 需要導入模塊: import prometheus_client [as 別名]
# 或者: from prometheus_client import start_http_server [as 別名]
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() 
開發者ID:wikimedia,項目名稱:search-MjoLniR,代碼行數:14,代碼來源:msearch_daemon.py

示例7: start

# 需要導入模塊: import prometheus_client [as 別名]
# 或者: from prometheus_client import start_http_server [as 別名]
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)) 
開發者ID:CHamburr,項目名稱:modmail,代碼行數:7,代碼來源:prometheus.py

示例8: _start_httpd

# 需要導入模塊: import prometheus_client [as 別名]
# 或者: from prometheus_client import start_http_server [as 別名]
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) 
開發者ID:OvalMoney,項目名稱:celery-exporter,代碼行數:10,代碼來源:core.py

示例9: start_httpd

# 需要導入模塊: import prometheus_client [as 別名]
# 或者: from prometheus_client import start_http_server [as 別名]
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) 
開發者ID:zerok,項目名稱:celery-prometheus-exporter,代碼行數:10,代碼來源:celery_prometheus_exporter.py


注:本文中的prometheus_client.start_http_server方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。