Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions monitoring/front_end_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from prometheus_client import start_http_server
from prometheus_client.core import GaugeMetricFamily, REGISTRY
import argparse
import logging

parser = argparse.ArgumentParser(
description='Spin up a node exporter for query_frontend.')
Expand All @@ -16,14 +17,24 @@
help='The name of docker container in clipper_network')
args = parser.parse_args()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add these lines right here:

logging.basicConfig(
    format='%(asctime)s %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s',
    datefmt='%y-%m-%d:%H:%M:%S',
    level=logging.INFO)

query_frontend_id = args.query_frontend_name
logging.basicConfig(
format='%(asctime)s %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s',
datefmt='%y-%m-%d:%H:%M:%S',
level=logging.INFO)
logger = logging.getLogger(__name__)

query_frontend_id = args.query_frontend_name
ADDRESS = 'http://{}/metrics'.format(query_frontend_id)
logger.info("Scraping {}".format(ADDRESS))


def load_metric():
res = requests.get(ADDRESS)
return res.json()
try:
res = requests.get(ADDRESS)
return res.json()
except Exception as e:
logger.warning("Scrape Failed! Error: {}\n".format(e))
return dict()


def multi_dict_unpacking(lst):
Expand All @@ -38,6 +49,10 @@ def multi_dict_unpacking(lst):


def parse_metric(metrics):
if len(metrics) == 0:
# Return empty dictionary if it's empty
return metrics

wo_type = list(itertools.chain.from_iterable(metrics.values()))
wo_type_flattened = list(itertools.chain([flatten(d) for d in wo_type]))
wo_type_joined = multi_dict_unpacking(wo_type_flattened)
Expand Down