mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-21 22:59:07 +00:00
Update monitor metric units for consistency and improve metric view legend handling
This commit is contained in:
parent
f67f1a64bd
commit
491a8f05bc
@ -603,7 +603,7 @@ export default class MonitorResourceUtil {
|
|||||||
monitorMetric.name = MonitorMetricType.IsOnline;
|
monitorMetric.name = MonitorMetricType.IsOnline;
|
||||||
monitorMetric.description = CheckOn.IsOnline + " status for monitor";
|
monitorMetric.description = CheckOn.IsOnline + " status for monitor";
|
||||||
monitorMetric.value = isOnline ? 1 : 0;
|
monitorMetric.value = isOnline ? 1 : 0;
|
||||||
monitorMetric.unit = CheckOn.IsOnline;
|
monitorMetric.unit = "";
|
||||||
monitorMetric.attributes = {
|
monitorMetric.attributes = {
|
||||||
monitorId: data.monitorId.toString(),
|
monitorId: data.monitorId.toString(),
|
||||||
projectId: data.projectId.toString(),
|
projectId: data.projectId.toString(),
|
||||||
@ -632,7 +632,7 @@ export default class MonitorResourceUtil {
|
|||||||
monitorMetric.name = MonitorMetricType.CPUUsagePercent;
|
monitorMetric.name = MonitorMetricType.CPUUsagePercent;
|
||||||
monitorMetric.description = CheckOn.CPUUsagePercent + " of Server/VM";
|
monitorMetric.description = CheckOn.CPUUsagePercent + " of Server/VM";
|
||||||
monitorMetric.value = basicMetrics.cpuMetrics.percentUsed;
|
monitorMetric.value = basicMetrics.cpuMetrics.percentUsed;
|
||||||
monitorMetric.unit = "Percent";
|
monitorMetric.unit = "%";
|
||||||
monitorMetric.attributes = {
|
monitorMetric.attributes = {
|
||||||
monitorId: data.monitorId.toString(),
|
monitorId: data.monitorId.toString(),
|
||||||
projectId: data.projectId.toString(),
|
projectId: data.projectId.toString(),
|
||||||
@ -654,7 +654,7 @@ export default class MonitorResourceUtil {
|
|||||||
monitorMetric.description =
|
monitorMetric.description =
|
||||||
CheckOn.MemoryUsagePercent + " of Server/VM";
|
CheckOn.MemoryUsagePercent + " of Server/VM";
|
||||||
monitorMetric.value = basicMetrics.memoryMetrics.percentUsed;
|
monitorMetric.value = basicMetrics.memoryMetrics.percentUsed;
|
||||||
monitorMetric.unit = "Percent";
|
monitorMetric.unit = "%";
|
||||||
monitorMetric.attributes = {
|
monitorMetric.attributes = {
|
||||||
monitorId: data.monitorId.toString(),
|
monitorId: data.monitorId.toString(),
|
||||||
projectId: data.projectId.toString(),
|
projectId: data.projectId.toString(),
|
||||||
@ -677,7 +677,7 @@ export default class MonitorResourceUtil {
|
|||||||
monitorMetric.description =
|
monitorMetric.description =
|
||||||
CheckOn.DiskUsagePercent + " of Server/VM";
|
CheckOn.DiskUsagePercent + " of Server/VM";
|
||||||
monitorMetric.value = diskMetric.percentUsed;
|
monitorMetric.value = diskMetric.percentUsed;
|
||||||
monitorMetric.unit = "Percent";
|
monitorMetric.unit = "%";
|
||||||
monitorMetric.attributes = {
|
monitorMetric.attributes = {
|
||||||
monitorId: data.monitorId.toString(),
|
monitorId: data.monitorId.toString(),
|
||||||
projectId: data.projectId.toString(),
|
projectId: data.projectId.toString(),
|
||||||
@ -796,7 +796,7 @@ export default class MonitorResourceUtil {
|
|||||||
.isOnline
|
.isOnline
|
||||||
? 1
|
? 1
|
||||||
: 0;
|
: 0;
|
||||||
monitorMetric.unit = CheckOn.IsOnline;
|
monitorMetric.unit = "";
|
||||||
monitorMetric.attributes = {
|
monitorMetric.attributes = {
|
||||||
monitorId: data.monitorId.toString(),
|
monitorId: data.monitorId.toString(),
|
||||||
projectId: data.projectId.toString(),
|
projectId: data.projectId.toString(),
|
||||||
@ -823,7 +823,7 @@ export default class MonitorResourceUtil {
|
|||||||
monitorMetric.value = (
|
monitorMetric.value = (
|
||||||
data.dataToProcess as ProbeMonitorResponse
|
data.dataToProcess as ProbeMonitorResponse
|
||||||
).responseCode;
|
).responseCode;
|
||||||
monitorMetric.unit = CheckOn.ResponseStatusCode;
|
monitorMetric.unit = "Status Code";
|
||||||
monitorMetric.attributes = {
|
monitorMetric.attributes = {
|
||||||
monitorId: data.monitorId.toString(),
|
monitorId: data.monitorId.toString(),
|
||||||
projectId: data.projectId.toString(),
|
projectId: data.projectId.toString(),
|
||||||
|
@ -4,11 +4,9 @@ import MonitorMetricType from "../../Types/Monitor/MonitorMetricType";
|
|||||||
import MonitorType from "../../Types/Monitor/MonitorType";
|
import MonitorType from "../../Types/Monitor/MonitorType";
|
||||||
|
|
||||||
class MonitorMetricTypeUtil {
|
class MonitorMetricTypeUtil {
|
||||||
|
|
||||||
|
|
||||||
public static getAggregationTypeByMonitorMetricType(
|
public static getAggregationTypeByMonitorMetricType(
|
||||||
monitorMetricType: MonitorMetricType,
|
monitorMetricType: MonitorMetricType,
|
||||||
): AggregationType {
|
): AggregationType {
|
||||||
switch (monitorMetricType) {
|
switch (monitorMetricType) {
|
||||||
case MonitorMetricType.ResponseTime:
|
case MonitorMetricType.ResponseTime:
|
||||||
return AggregationType.Avg;
|
return AggregationType.Avg;
|
||||||
@ -60,18 +58,19 @@ class MonitorMetricTypeUtil {
|
|||||||
monitorType === MonitorType.Website
|
monitorType === MonitorType.Website
|
||||||
) {
|
) {
|
||||||
return [
|
return [
|
||||||
|
MonitorMetricType.IsOnline,
|
||||||
MonitorMetricType.ResponseTime,
|
MonitorMetricType.ResponseTime,
|
||||||
MonitorMetricType.ResponseStatusCode,
|
MonitorMetricType.ResponseStatusCode,
|
||||||
MonitorMetricType.IsOnline,
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (monitorType === MonitorType.Server) {
|
if (monitorType === MonitorType.Server) {
|
||||||
return [
|
return [
|
||||||
|
MonitorMetricType.IsOnline,
|
||||||
MonitorMetricType.DiskUsagePercent,
|
MonitorMetricType.DiskUsagePercent,
|
||||||
MonitorMetricType.CPUUsagePercent,
|
MonitorMetricType.CPUUsagePercent,
|
||||||
MonitorMetricType.MemoryUsagePercent,
|
MonitorMetricType.MemoryUsagePercent,
|
||||||
MonitorMetricType.IsOnline,
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +87,7 @@ class MonitorMetricTypeUtil {
|
|||||||
monitorType === MonitorType.IP ||
|
monitorType === MonitorType.IP ||
|
||||||
monitorType === MonitorType.Port
|
monitorType === MonitorType.Port
|
||||||
) {
|
) {
|
||||||
return [MonitorMetricType.ResponseTime, MonitorMetricType.IsOnline];
|
return [MonitorMetricType.IsOnline, MonitorMetricType.ResponseTime ];
|
||||||
}
|
}
|
||||||
|
|
||||||
return [];
|
return [];
|
||||||
|
@ -234,17 +234,20 @@ const MetricView: FunctionComponent<ComponentProps> = (
|
|||||||
},
|
},
|
||||||
yAxis: {
|
yAxis: {
|
||||||
// legend is the unit of the metric
|
// legend is the unit of the metric
|
||||||
legend:
|
legend: "",
|
||||||
metricNamesAndUnits.find((m: MetricNameAndUnit) => {
|
|
||||||
return (
|
|
||||||
m.metricName ===
|
|
||||||
queryConfig.metricQueryData.filterData.metricName
|
|
||||||
);
|
|
||||||
})?.unit || "",
|
|
||||||
options: {
|
options: {
|
||||||
type: YAxisType.Number,
|
type: YAxisType.Number,
|
||||||
formatter: (value: number) => {
|
formatter: (value: number) => {
|
||||||
return `${value}`;
|
const metricNameAndUnit: MetricNameAndUnit | undefined =
|
||||||
|
metricNamesAndUnits.find((m: MetricNameAndUnit) => {
|
||||||
|
return (
|
||||||
|
m.metricName ===
|
||||||
|
queryConfig.metricQueryData.filterData.metricName
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
return `${value} ${metricNameAndUnit?.unit || ""}`;
|
||||||
},
|
},
|
||||||
precision: YAxisPrecision.NoDecimals,
|
precision: YAxisPrecision.NoDecimals,
|
||||||
max: "auto",
|
max: "auto",
|
||||||
@ -291,6 +294,7 @@ const MetricView: FunctionComponent<ComponentProps> = (
|
|||||||
},
|
},
|
||||||
groupBy: {
|
groupBy: {
|
||||||
name: true,
|
name: true,
|
||||||
|
unit: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -444,7 +448,12 @@ const MetricView: FunctionComponent<ComponentProps> = (
|
|||||||
});
|
});
|
||||||
|
|
||||||
// if hideQueryElements is true then we should fetch the results immediately because apply button is hidden
|
// if hideQueryElements is true then we should fetch the results immediately because apply button is hidden
|
||||||
if (props.hideQueryElements) {
|
if (
|
||||||
|
props.hideQueryElements &&
|
||||||
|
startAndEndDate &&
|
||||||
|
startAndEndDate.startValue &&
|
||||||
|
startAndEndDate.endValue
|
||||||
|
) {
|
||||||
fetchAggregatedResults().catch((err: Error) => {
|
fetchAggregatedResults().catch((err: Error) => {
|
||||||
setMetricResultsError(
|
setMetricResultsError(
|
||||||
API.getFriendlyErrorMessage(err as Error),
|
API.getFriendlyErrorMessage(err as Error),
|
||||||
|
@ -11,7 +11,6 @@ import InBetween from "Common/Types/BaseDatabase/InBetween";
|
|||||||
import MetricView from "../Metrics/MetricView";
|
import MetricView from "../Metrics/MetricView";
|
||||||
import { MetricQueryConfigData } from "../Metrics/MetricQueryConfig";
|
import { MetricQueryConfigData } from "../Metrics/MetricQueryConfig";
|
||||||
import DashboardNavigation from "../../Utils/Navigation";
|
import DashboardNavigation from "../../Utils/Navigation";
|
||||||
import AggregationType from "Common/Types/BaseDatabase/AggregationType";
|
|
||||||
import MonitorMetricType from "Common/Types/Monitor/MonitorMetricType";
|
import MonitorMetricType from "Common/Types/Monitor/MonitorMetricType";
|
||||||
import MonitorType from "Common/Types/Monitor/MonitorType";
|
import MonitorType from "Common/Types/Monitor/MonitorType";
|
||||||
import API from "Common/UI/Utils/API/API";
|
import API from "Common/UI/Utils/API/API";
|
||||||
@ -110,9 +109,10 @@ const MonitorMetricsElement: FunctionComponent<ComponentProps> = (
|
|||||||
monitorId: props.monitorId.toString(),
|
monitorId: props.monitorId.toString(),
|
||||||
projectId: DashboardNavigation.getProjectId()?.toString() || "",
|
projectId: DashboardNavigation.getProjectId()?.toString() || "",
|
||||||
},
|
},
|
||||||
aggegationType: MonitorMetricTypeUtil.getAggregationTypeByMonitorMetricType(
|
aggegationType:
|
||||||
monitorMetricType,
|
MonitorMetricTypeUtil.getAggregationTypeByMonitorMetricType(
|
||||||
),
|
monitorMetricType,
|
||||||
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user