def get_location_client_server_metrics(self, location_id, client_id, server_id, timebin, starttime, endtime): ''' Get data for specific location + client + server at a specific frequency between start and stop times for a specific client ISP. location_id = id string of location. client_id = id of client. server_id = id of server. timebin = time aggregation key. starttime = start time for metric query. endtime = end time for metric query. ''' # Create Row Key agg_name = "{0}_{1}_{2}".format(TABLE_KEYS["servers"], TABLE_KEYS["clients"], TABLE_KEYS["locations"]) table_config = get_table_config(self.table_configs, timebin, agg_name) key_fields = du.get_key_fields([location_id, client_id, server_id], table_config) formatted = bt.get_time_metric_results( key_fields, self.get_pool(), timebin, starttime, endtime, table_config, "locations_clients_servers") # set the ID to be the Client ISP ID if formatted['meta']: formatted["meta"]["id"] = "_".join([location_id, client_id, server_id]) return formatted
def get_server_info(self, server_id): ''' Get info for a client server_id = id of server. ''' # we are using a hack from list tables # so grab the first match from a list table faceted by server ids' table_name = du.list_table("clients", "servers") table_config = get_table_config(self.table_configs, None, table_name) key_fields = du.get_key_fields([server_id], table_config) prefix_key = du.BIGTABLE_KEY_DELIM.join(key_fields) results = bt.scan_table(table_config, self.get_pool(), prefix=prefix_key, limit=1, filter=FamilyNameRegexFilter('meta')) result = {} if len(results) > 0: result = results[0] return result
def get_location_server_metrics(self, location_id, server_id, timebin, starttime, endtime): ''' Get data for specific location + server at a specific frequency between start and stop times for a specific client ISP. location_id = id string of location. server_id = id of server. timebin = time aggregation key. starttime = start time for metric query. endtime = end time for metric query. ''' # Create Row Key agg_name = TABLE_KEYS["servers"] + '_' + TABLE_KEYS["locations"] table_config = get_table_config(self.table_configs, timebin, agg_name) # TODO: the direction of the keys don't match the table name key_fields = du.get_key_fields([location_id, server_id], table_config) formatted = bt.get_time_metric_results( key_fields, self.get_pool(), timebin, starttime, endtime, table_config, "locations_servers") # set the ID to be the Client ISP ID if formatted['meta']: formatted["meta"]["id"] = "_".join([location_id, server_id]) return formatted
def get_server_info(self, server_id): ''' Get info for a client server_id = id of server. ''' # we are using a hack from list tables # so grab the first match from a list table faceted by server ids' table_name = du.list_table("clients", "servers") table_config = get_table_config(self.table_configs, None, table_name) key_fields = du.get_key_fields([server_id], table_config) return get_bt_results(key_fields, table_config, self.get_pool())
def get_server_info(self, server_id): ''' Get info for a client server_id = id of server. ''' # we are using a hack from list tables # so grab the first match from a list table faceted by server ids' table_name = du.list_table("clients", "servers") table_config = get_table_config(self.table_configs, None, table_name) key_fields = du.get_key_fields([server_id], table_config) return get_bt_results(key_fields, table_config, self.get_pool())
def get_client_metrics(self, client_id, timebin, starttime, endtime): ''' Get data for client location at a specific timebin between start and stop times. client_id = id string of client. timebin = time aggregation key. starttime = start time for metric query. endtime = end time for metric query. ''' table_config = get_table_config(self.table_configs, timebin, TABLE_KEYS["clients"]) key_fields = du.get_key_fields([client_id], table_config) formatted = bt.get_time_metric_results(key_fields, self.get_pool(), timebin, starttime, endtime, table_config, "clients") return formatted
def get_location_client_isp_info(self, location_id, client_id): ''' Get static information about location_id = id string of location. client_id = id string of client. ''' config_id = du.list_table('clients', 'locations') table_config = get_table_config(self.table_configs, None, config_id) key_fields = du.get_key_fields([location_id, client_id], table_config) row_key = du.BIGTABLE_KEY_DELIM.join(key_fields) results = [] results = bt.get_row(table_config, self.get_pool(), row_key) return results
def get_location_info(self, location_id): ''' Get info about specific location location_id = id string of location. ''' table_config = get_table_config(self.table_configs, None, du.list_table('locations')) # add empty field to get child location in there location_key_fields = du.get_key_fields(["info", location_id], table_config) row_key = du.BIGTABLE_KEY_DELIM.join(location_key_fields) row = "" row = bt.get_row(table_config, self.get_pool(), row_key) return row
def get_server_metrics(self, server_id, timebin, starttime, endtime): ''' Get data for specific location at a specific frequency between start and stop times. server_id = id of server. timebin = time aggregation key. starttime = start time for metric query. endtime = end time for metric query. ''' table_config = get_table_config(self.table_configs, timebin, TABLE_KEYS["servers"]) location_key_fields = du.get_key_fields([server_id], table_config) formatted = bt.get_time_metric_results( location_key_fields, self.get_pool(), timebin, starttime, endtime, table_config, "servers") return formatted
def get_client_server_metrics(self, client_id, server_id, timebin, starttime, endtime): ''' Get data for a specific client + server at a timebin between start and stop times. client_id = id string of client. server_id = id of server. timebin = time aggregation key. starttime = start time for metric query. endtime = end time for metric query. ''' agg_name = TABLE_KEYS["servers"] + '_' + TABLE_KEYS["clients"] table_config = get_table_config(self.table_configs, timebin, agg_name) key_fields = du.get_key_fields([server_id, client_id], table_config) formatted = bt.get_time_metric_results(key_fields, self.get_pool(), timebin, starttime, endtime, table_config, "clients") return formatted
def get_client_metrics(self, client_id, timebin, starttime, endtime): ''' Get data for client location at a specific timebin between start and stop times. client_id = id string of client. timebin = time aggregation key. starttime = start time for metric query. endtime = end time for metric query. ''' table_config = get_table_config(self.table_configs, timebin, TABLE_KEYS["clients"]) key_fields = du.get_key_fields([client_id], table_config) formatted = bt.get_time_metric_results( key_fields, self.get_pool(), timebin, starttime, endtime, table_config, "clients") return formatted
def get_list_data(self, entity_id, entity_type, query_type, include_data): ''' Helper method to get out data from a list table. entity_id = id of entity to look for entity_type = [locations, clients, servers] query_type = [locations, clients, servers] - what we are faceting on include_data = boolean to indicate if data should be queried and returned. ''' config_id = du.list_table(query_type, entity_type) metric_name = "_".join([entity_type, query_type]) table_config = get_table_config(self.table_configs, None, config_id) key_fields = du.get_key_fields([entity_id], table_config) results = bt.get_list_table_results(key_fields, self.get_pool(), include_data, table_config, metric_name) return {"results": results}
def get_server_metrics(self, server_id, timebin, starttime, endtime): ''' Get data for specific location at a specific frequency between start and stop times. server_id = id of server. timebin = time aggregation key. starttime = start time for metric query. endtime = end time for metric query. ''' table_config = get_table_config(self.table_configs, timebin, TABLE_KEYS["servers"]) location_key_fields = du.get_key_fields([server_id], table_config) formatted = bt.get_time_metric_results(location_key_fields, self.get_pool(), timebin, starttime, endtime, table_config, "servers") return formatted
def get_list_data(self, entity_id, entity_type, query_type, include_data): ''' Helper method to get out data from a list table. entity_id = id of entity to look for entity_type = [locations, clients, servers] query_type = [locations, clients, servers] - what we are faceting on include_data = boolean indicates if data should be queried and returned. ''' config_id = du.list_table(query_type, entity_type) metric_name = "_".join([entity_type, query_type]) table_config = get_table_config(self.table_configs, None, config_id) key_fields = du.get_key_fields([entity_id], table_config) results = bt.get_list_table_results( key_fields, self.get_pool(), include_data, table_config, metric_name) return {"results": results}
def get_client_server_metrics(self, client_id, server_id, timebin, starttime, endtime): ''' Get data for a specific client + server at a timebin between start and stop times. client_id = id string of client. server_id = id of server. timebin = time aggregation key. starttime = start time for metric query. endtime = end time for metric query. ''' agg_name = TABLE_KEYS["servers"] + '_' + TABLE_KEYS["clients"] table_config = get_table_config(self.table_configs, timebin, agg_name) key_fields = du.get_key_fields([server_id, client_id], table_config) formatted = bt.get_time_metric_results( key_fields, self.get_pool(), timebin, starttime, endtime, table_config, "clients") return formatted