def __publish_to_gateway(self, metric_map):
    """Helper function to publish polled metrics to the gateway."""

    # When we push to the gateway, prometheus will collect the metrics.
    # It doesnt have a way to inject the metrics. We've already collected
    # them so dont want to do that again. Here we will cache the metrics that
    # were injected along with our timestamp. Later in the collect method,
    # we'll check the cache time to see if it is recent before we poll for
    # the metrics (as in the non-gateway use case).
    self.__last_collect_metric_map = metric_map
    self.__last_collect_time = time.time()

    all_metrics = self.collect_with_metrics(metric_map)
    push_to_gateway(self.__push_gateway, "SpinnakerMonitoringDaemon", REGISTRY)
    return len(all_metrics)
 def send(self, **options):
     self.options.update(options)
     config = self.options.copy()
     prefix = config.pop('prefix', None)
     u_name = config.pop('usrname', None)
     u_pass = config.pop('usrpass', None)
     config.setdefault(
         'handler',
         partial(basic_auth_handler, username=u_name, password=u_pass))
     return push_to_gateway(**config)
Beispiel #3
0
 def submit(self):
     push_to_gateway(self.endpoint, "invertpdf", self.registry)
 def _do_flush_updated_metrics(self, updated_metrics):
     """Pushes metrics to prometheus."""
     push_to_gateway(self.__push_gateway, "buildtool", REGISTRY)