Loading src/slice/service/slice_grouper/MetricsExporter.py +6 −6 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ MSG_ERROR_MAX_RETRIES = 'Maximum number of retries achieved: {:d}' METRICSDB_HOSTNAME = os.environ.get('METRICSDB_HOSTNAME') METRICSDB_ILP_PORT = int(os.environ.get('METRICSDB_ILP_PORT')) METRICSDB_REST_PORT = int(os.environ.get('METRICSDB_REST_PORT')) METRICSDB_TABLE = 'slice_groups' METRICSDB_TABLE_SLICE_GROUPS = os.environ.get('METRICSDB_TABLE_SLICE_GROUPS') COLORS = { 'platinum': '#E5E4E2', Loading @@ -46,7 +46,7 @@ SQL_MARK_DELETED = "UPDATE {:s} SET is_deleted='true' WHERE slice_uuid='{:s}';" class MetricsExporter(): def create_table(self) -> None: sql_query = ' '.join([ 'CREATE TABLE IF NOT EXISTS {:s} ('.format(str(METRICSDB_TABLE)), 'CREATE TABLE IF NOT EXISTS {:s} ('.format(str(METRICSDB_TABLE_SLICE_GROUPS)), ','.join([ 'timestamp TIMESTAMP', 'slice_uuid SYMBOL', Loading @@ -62,9 +62,9 @@ class MetricsExporter(): try: result = self.rest_request(sql_query) if not result: raise Exception LOGGER.info('Table {:s} created'.format(str(METRICSDB_TABLE))) LOGGER.info('Table {:s} created'.format(str(METRICSDB_TABLE_SLICE_GROUPS))) except Exception as e: LOGGER.warning('Table {:s} cannot be created. {:s}'.format(str(METRICSDB_TABLE), str(e))) LOGGER.warning('Table {:s} cannot be created. {:s}'.format(str(METRICSDB_TABLE_SLICE_GROUPS), str(e))) raise def export_point( Loading @@ -80,7 +80,7 @@ class MetricsExporter(): for retry in range(MAX_RETRIES): try: with Sender(METRICSDB_HOSTNAME, METRICSDB_ILP_PORT) as sender: sender.row(METRICSDB_TABLE, symbols=symbols, columns=columns, at=dt_timestamp) sender.row(METRICSDB_TABLE_SLICE_GROUPS, symbols=symbols, columns=columns, at=dt_timestamp) sender.flush() LOGGER.info(MSG_EXPORT_EXECUTED.format(str(dt_timestamp), str(symbols), str(columns))) return Loading @@ -91,7 +91,7 @@ class MetricsExporter(): raise Exception(MSG_ERROR_MAX_RETRIES.format(MAX_RETRIES)) def delete_point(self, slice_uuid : str) -> None: sql_query = SQL_MARK_DELETED.format(str(METRICSDB_TABLE), slice_uuid) sql_query = SQL_MARK_DELETED.format(str(METRICSDB_TABLE_SLICE_GROUPS), slice_uuid) try: result = self.rest_request(sql_query) if not result: raise Exception Loading Loading
src/slice/service/slice_grouper/MetricsExporter.py +6 −6 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ MSG_ERROR_MAX_RETRIES = 'Maximum number of retries achieved: {:d}' METRICSDB_HOSTNAME = os.environ.get('METRICSDB_HOSTNAME') METRICSDB_ILP_PORT = int(os.environ.get('METRICSDB_ILP_PORT')) METRICSDB_REST_PORT = int(os.environ.get('METRICSDB_REST_PORT')) METRICSDB_TABLE = 'slice_groups' METRICSDB_TABLE_SLICE_GROUPS = os.environ.get('METRICSDB_TABLE_SLICE_GROUPS') COLORS = { 'platinum': '#E5E4E2', Loading @@ -46,7 +46,7 @@ SQL_MARK_DELETED = "UPDATE {:s} SET is_deleted='true' WHERE slice_uuid='{:s}';" class MetricsExporter(): def create_table(self) -> None: sql_query = ' '.join([ 'CREATE TABLE IF NOT EXISTS {:s} ('.format(str(METRICSDB_TABLE)), 'CREATE TABLE IF NOT EXISTS {:s} ('.format(str(METRICSDB_TABLE_SLICE_GROUPS)), ','.join([ 'timestamp TIMESTAMP', 'slice_uuid SYMBOL', Loading @@ -62,9 +62,9 @@ class MetricsExporter(): try: result = self.rest_request(sql_query) if not result: raise Exception LOGGER.info('Table {:s} created'.format(str(METRICSDB_TABLE))) LOGGER.info('Table {:s} created'.format(str(METRICSDB_TABLE_SLICE_GROUPS))) except Exception as e: LOGGER.warning('Table {:s} cannot be created. {:s}'.format(str(METRICSDB_TABLE), str(e))) LOGGER.warning('Table {:s} cannot be created. {:s}'.format(str(METRICSDB_TABLE_SLICE_GROUPS), str(e))) raise def export_point( Loading @@ -80,7 +80,7 @@ class MetricsExporter(): for retry in range(MAX_RETRIES): try: with Sender(METRICSDB_HOSTNAME, METRICSDB_ILP_PORT) as sender: sender.row(METRICSDB_TABLE, symbols=symbols, columns=columns, at=dt_timestamp) sender.row(METRICSDB_TABLE_SLICE_GROUPS, symbols=symbols, columns=columns, at=dt_timestamp) sender.flush() LOGGER.info(MSG_EXPORT_EXECUTED.format(str(dt_timestamp), str(symbols), str(columns))) return Loading @@ -91,7 +91,7 @@ class MetricsExporter(): raise Exception(MSG_ERROR_MAX_RETRIES.format(MAX_RETRIES)) def delete_point(self, slice_uuid : str) -> None: sql_query = SQL_MARK_DELETED.format(str(METRICSDB_TABLE), slice_uuid) sql_query = SQL_MARK_DELETED.format(str(METRICSDB_TABLE_SLICE_GROUPS), slice_uuid) try: result = self.rest_request(sql_query) if not result: raise Exception Loading