Skip to content

Commit

Permalink
Add utility method to determine aggregation type by monitor metric type
Browse files Browse the repository at this point in the history
  • Loading branch information
simlarsen committed Nov 7, 2024
1 parent a31ef12 commit f67f1a6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
26 changes: 26 additions & 0 deletions Common/Utils/Monitor/MonitorMetricType.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,34 @@
import AggregationType from "../../Types/BaseDatabase/AggregationType";
import { CheckOn } from "../../Types/Monitor/CriteriaFilter";
import MonitorMetricType from "../../Types/Monitor/MonitorMetricType";
import MonitorType from "../../Types/Monitor/MonitorType";

class MonitorMetricTypeUtil {


public static getAggregationTypeByMonitorMetricType(
monitorMetricType: MonitorMetricType,
): AggregationType {
switch (monitorMetricType) {
case MonitorMetricType.ResponseTime:
return AggregationType.Avg;
case MonitorMetricType.ResponseStatusCode:
return AggregationType.Max;
case MonitorMetricType.IsOnline:
return AggregationType.Min;
case MonitorMetricType.DiskUsagePercent:
return AggregationType.Max;
case MonitorMetricType.CPUUsagePercent:
return AggregationType.Avg;
case MonitorMetricType.MemoryUsagePercent:
return AggregationType.Avg;
case MonitorMetricType.ExecutionTime:
return AggregationType.Avg;
default:
throw new Error("Invalid MonitorMetricType value");
}
}

public static getMonitorMeticTypeByCheckOn(
checkOn: CheckOn,
): MonitorMetricType {
Expand Down
4 changes: 3 additions & 1 deletion Dashboard/src/Components/Monitor/MonitorMetrics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ const MonitorMetricsElement: FunctionComponent<ComponentProps> = (
monitorId: props.monitorId.toString(),
projectId: DashboardNavigation.getProjectId()?.toString() || "",
},
aggegationType: AggregationType.Avg,
aggegationType: MonitorMetricTypeUtil.getAggregationTypeByMonitorMetricType(
monitorMetricType,
),
},
},
});
Expand Down

0 comments on commit f67f1a6

Please sign in to comment.