Exemple #1
0
 def gen_responses(self, groups, payload):
     # converts groups of requests into a single list of responses
     headers = auth.headers()
     responses = reduce(lambda x, y: x + y, [
         self.get_metric_data(self.host, self.tenant, g, payload, headers)
         for g in groups
     ])
     responses = responses or []
     return responses
 def gen_responses(self, groups, payload):
     # converts groups of requests into a single list of responses
     headers = auth.headers()
     responses = reduce(lambda x, y: x + y,
                        [self.get_metric_data(self.host,
                                              self.tenant,
                                              g,
                                              payload,
                                              headers)
                         for g in groups])
     responses = responses or []
     return responses
Exemple #3
0
    def getEvents(self, start_time, end_time, tags):
        url = self.find_events_endpoint(self.bf_query_endpoint, self.tenant)
        payload = {'from': start_time * 1000, 'until': end_time * 1000}

        if tags is not None:
            payload['tags'] = tags
        headers = auth.headers()

        r = self.make_request(url, payload, headers)
        r = r.json()
        for event in r:
            event['when'] = int(event['when'] / 1000)
        return r
    def find_nodes_from_bf(self, query):
        logger.info("BluefloodClient.find_nodes_from_bf: %s", str(query))
        payload = {'query': query.pattern}
        headers = auth.headers()

        endpoint = self.find_nodes_endpoint(self.bf_query_endpoint,
                                            self.tenant)
        r = self.make_request(endpoint, payload, headers)

        if r.status_code != 200:
            logger.info("BF(find_metrics_with_enum_values) responded "
                        "with response code: [%s] endpoint [%s]",
                        r.status_code, endpoint)

        return r.json()
    def getEvents(self, start_time, end_time, tags):
        url = self.find_events_endpoint(self.bf_query_endpoint, self.tenant)
        payload = {
            'from': start_time * 1000,
            'until': end_time * 1000
        }

        if tags is not None:
            payload['tags'] = tags
        headers = auth.headers()

        r = self.make_request(url, payload, headers)
        r = r.json()
        for event in r:
            event['when'] = int(event['when'] / 1000)
        return r
Exemple #6
0
    def find_nodes_from_bf(self, query):
        logger.info("BluefloodClient.find_nodes_from_bf: %s", str(query))
        payload = {'query': query.pattern}
        headers = auth.headers()

        endpoint = self.find_nodes_endpoint(self.bf_query_endpoint,
                                            self.tenant)
        r = self.make_request(endpoint, payload, headers)

        if r.status_code != 200:
            logger.info(
                "BF(find_metrics_with_enum_values) responded "
                "with response code: [%s] endpoint [%s]", r.status_code,
                endpoint)

        return r.json()
 def find_metrics_with_enum_values(self, query):
     # BF search command that returns enum values as well as metric names
     logger.info("BluefloodClient.find_metrics: %s", str(query))
     payload = {'query': query}
     headers = auth.headers()
     endpoint = self.find_metrics_endpoint(self.bf_query_endpoint,
                                           self.tenant)
     r = self.make_request(endpoint, payload, headers)
     ret_dict = {}
     if r.status_code == 200:
         for m in r.json():
             if 'enum_values' in m:
                 v = m['enum_values']
             else:
                 v = None
             ret_dict[m['metric']] = v
         return ret_dict
     else:
         return {}
Exemple #8
0
 def find_metrics_with_enum_values(self, query):
     # BF search command that returns enum values as well as metric names
     logger.info("BluefloodClient.find_metrics: %s", str(query))
     payload = {'query': query}
     headers = auth.headers()
     endpoint = self.find_metrics_endpoint(self.bf_query_endpoint,
                                           self.tenant)
     r = self.make_request(endpoint, payload, headers)
     ret_dict = {}
     if r.status_code == 200:
         for m in r.json():
             if 'enum_values' in m:
                 v = m['enum_values']
             else:
                 v = None
             ret_dict[m['metric']] = v
         return ret_dict
     else:
         logger.info(
             "BF(find_metrics_with_enum_values) responded with "
             "response code: [%s] endpoint [%s]", r.status_code, endpoint)
         return {}