from frostfs_testlib.hosting import Host from frostfs_testlib.shell.interfaces import CommandResult class Metrics: def __init__(self, host: Host, metrics_endpoint: str) -> None: self.storage = StorageMetrics(host, metrics_endpoint) class StorageMetrics: """ Class represents storage metrics in a cluster """ def __init__(self, host: Host, metrics_endpoint: str) -> None: self.host = host self.metrics_endpoint = metrics_endpoint def get_metrics_search_by_greps(self, **greps) -> CommandResult: """ Get a metrics, search by: cid, metric_type, shard_id etc. Args: greps: dict of grep-command-name and value for example get_metrics_search_by_greps(command='container_objects_total', cid='123456') Return: result of metrics """ shell = self.host.get_shell() additional_greps = " |grep ".join([grep_command for grep_command in greps.values()]) result = shell.exec(f"curl -s {self.metrics_endpoint} | grep {additional_greps}") return result def get_all_metrics(self) -> CommandResult: shell = self.host.get_shell() result = shell.exec(f"curl -s {self.metrics_endpoint}") return result