Expose prometheus metrics for backfiller and downloader

mike/downloader/handle-404
Mike Lang 6 years ago committed by Christopher Usher
parent d90f01b8ce
commit b4b315b6bc

@ -10,6 +10,7 @@ import time
import uuid
import requests
import prometheus_client as prom
import common
@ -219,7 +220,7 @@ def backfill_node(base_dir, node, stream, variants, hours=None, segment_order='r
logging.info('Finished backfilling from {}'.format(node))
def main(base_dir='.', stream='', variants='', fill_wait=5, full_fill_wait=180, sleep_time=1):
def main(base_dir='.', stream='', variants='', fill_wait=5, full_fill_wait=180, sleep_time=1, metrics_port=8002):
"""Prototype backfiller service.
Do a backfill of the last 3 hours from stream/variants from all nodes
@ -235,6 +236,7 @@ def main(base_dir='.', stream='', variants='', fill_wait=5, full_fill_wait=180,
variants = variants.split(',') if variants else []
common.PromLogCountsHandler.install()
prom.start_http_server(metrics_port)
logging.info('Starting backfilling {} with {} as variants to {}'.format(stream, ', '.join(variants), base_dir))

@ -13,6 +13,7 @@ from contextlib import contextmanager
import dateutil.parser
import gevent
import gevent.event
import prometheus_client as prom
import requests
from monotonic import monotonic
@ -490,11 +491,12 @@ class SegmentGetter(object):
common.rename(temp_path, full_path)
def main(channel, base_dir=".", qualities=""):
def main(channel, base_dir=".", qualities="", metrics_port=8001):
qualities = qualities.split(",") if qualities else []
manager = StreamsManager(channel, base_dir, qualities)
gevent.signal(signal.SIGTERM, manager.stop) # shut down on sigterm
common.PromLogCountsHandler.install()
prom.start_http_server(metrics_port)
logging.info("Starting up")
manager.run()
logging.info("Gracefully stopped")

Loading…
Cancel
Save