From 07a1bb1dc504dac31bfe17d68e72981c1c2a045a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B0=D0=B2=D0=B5=D0=BB=20=D0=96=D1=83=D0=BA=D0=BE?= =?UTF-8?q?=D0=B2?= <33721692+LeaveMyYard@users.noreply.github.com> Date: Mon, 20 Mar 2023 20:21:42 +0200 Subject: Fix prometheus integration --- robusta_krr/formatters/table.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'robusta_krr/formatters/table.py') diff --git a/robusta_krr/formatters/table.py b/robusta_krr/formatters/table.py index 9eda49e..327d66a 100644 --- a/robusta_krr/formatters/table.py +++ b/robusta_krr/formatters/table.py @@ -12,6 +12,7 @@ from robusta_krr.utils import resource_units NONE_LITERAL = "none" NAN_LITERAL = "?" PRESCISION = 4 +ALLOWED_DIFFERENCE = 0.05 class TableFormatter(BaseFormatter): @@ -28,10 +29,13 @@ class TableFormatter(BaseFormatter): return resource_units.format(value, prescision=prescision) def _format_request_str(self, item: ResourceScan, resource: ResourceType, selector: str) -> str: + allocated = getattr(item.object.allocations, selector)[resource] + recommended = getattr(item.recommended, selector)[resource] + return ( - self._format_united_decimal(getattr(item.object.allocations, selector)[resource]) + self._format_united_decimal(allocated) + " -> " - + self._format_united_decimal(getattr(item.recommended, selector)[resource], prescision=PRESCISION) + + self._format_united_decimal(recommended, prescision=PRESCISION) ) def format(self, result: Result) -> Table: @@ -49,6 +53,7 @@ class TableFormatter(BaseFormatter): table.add_column("Cluster", style="cyan") table.add_column("Namespace", style="cyan") table.add_column("Name", style="cyan") + table.add_column("Pods", style="cyan") table.add_column("Type", style="cyan") table.add_column("Container", style="cyan") for resource in ResourceType: @@ -69,6 +74,7 @@ class TableFormatter(BaseFormatter): item.object.cluster if full_info_row else "", item.object.namespace if full_info_row else "", item.object.name if full_info_row else "", + str(len(item.object.pods)) if full_info_row else "", item.object.kind if full_info_row else "", item.object.container, *[ -- cgit v1.2.3