@oneuptime/common 7.0.3225 → 7.0.3233
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Models/AnalyticsModels/Index.ts +0 -2
- package/Models/AnalyticsModels/Metric.ts +39 -1
- package/Models/DatabaseModels/Alert.ts +0 -1
- package/Models/DatabaseModels/Incident.ts +0 -1
- package/Models/DatabaseModels/IncidentStateTimeline.ts +0 -1
- package/Models/DatabaseModels/MonitorStatusTimeline.ts +0 -1
- package/Server/API/BaseAnalyticsAPI.ts +11 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1731433043136-MigrationName.ts +17 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1731433309124-MigrationName.ts +17 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1731435267537-MigrationName.ts +17 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1731435514287-MigrationName.ts +17 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +8 -0
- package/Server/Services/AnalyticsDatabaseService.ts +17 -7
- package/Server/Services/DatabaseService.ts +11 -3
- package/Server/Services/Index.ts +0 -2
- package/Server/Types/AnalyticsDatabase/AggregateBy.ts +4 -4
- package/Server/Utils/AnalyticsDatabase/StatementGenerator.ts +18 -4
- package/Server/Utils/Browser.ts +194 -0
- package/Server/Utils/Monitor/Criteria/CompareCriteria.ts +3 -0
- package/Server/Utils/Monitor/Criteria/EvaluateOverTime.ts +21 -21
- package/Server/Utils/Monitor/MonitorIncident.ts +0 -2
- package/Server/Utils/Monitor/MonitorResource.ts +186 -127
- package/Server/Utils/Telemetry/Telemetry.ts +154 -0
- package/Types/BaseDatabase/AggregateBy.ts +2 -0
- package/Types/BaseDatabase/AggregatedModel.ts +3 -0
- package/Types/Html.ts +11 -0
- package/Types/Metrics/MetricsQuery.ts +8 -0
- package/Types/Monitor/CriteriaFilter.ts +0 -36
- package/Types/Monitor/MonitorMetricType.ts +11 -0
- package/Types/Monitor/MonitorType.ts +18 -0
- package/UI/Components/Charts/ChartGroup/ChartGroup.tsx +1 -1
- package/UI/Components/Charts/ChartLibrary/LineChart/LineChart.tsx +2 -2
- package/UI/Components/Charts/Line/LineChart.tsx +2 -2
- package/UI/Components/ModelTable/TableView.tsx +1 -0
- package/UI/Components/MoreMenu/MoreMenuItem.tsx +2 -0
- package/Utils/Monitor/MonitorMetricType.ts +142 -0
- package/build/dist/Models/AnalyticsModels/Index.js +0 -2
- package/build/dist/Models/AnalyticsModels/Index.js.map +1 -1
- package/build/dist/Models/AnalyticsModels/Metric.js +36 -1
- package/build/dist/Models/AnalyticsModels/Metric.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Alert.js +0 -1
- package/build/dist/Models/DatabaseModels/Alert.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Incident.js +0 -1
- package/build/dist/Models/DatabaseModels/Incident.js.map +1 -1
- package/build/dist/Models/DatabaseModels/IncidentStateTimeline.js +0 -1
- package/build/dist/Models/DatabaseModels/IncidentStateTimeline.js.map +1 -1
- package/build/dist/Models/DatabaseModels/MonitorStatusTimeline.js +0 -1
- package/build/dist/Models/DatabaseModels/MonitorStatusTimeline.js.map +1 -1
- package/build/dist/Server/API/BaseAnalyticsAPI.js +7 -0
- package/build/dist/Server/API/BaseAnalyticsAPI.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1731433043136-MigrationName.js +12 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1731433043136-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1731433309124-MigrationName.js +12 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1731433309124-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1731435267537-MigrationName.js +12 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1731435267537-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1731435514287-MigrationName.js +12 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1731435514287-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +8 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Services/AnalyticsDatabaseService.js +7 -0
- package/build/dist/Server/Services/AnalyticsDatabaseService.js.map +1 -1
- package/build/dist/Server/Services/DatabaseService.js +6 -1
- package/build/dist/Server/Services/DatabaseService.js.map +1 -1
- package/build/dist/Server/Services/Index.js +0 -2
- package/build/dist/Server/Services/Index.js.map +1 -1
- package/build/dist/Server/Types/AnalyticsDatabase/AggregateBy.js +4 -4
- package/build/dist/Server/Utils/AnalyticsDatabase/StatementGenerator.js +13 -4
- package/build/dist/Server/Utils/AnalyticsDatabase/StatementGenerator.js.map +1 -1
- package/build/dist/Server/Utils/Browser.js +128 -0
- package/build/dist/Server/Utils/Browser.js.map +1 -0
- package/build/dist/Server/Utils/Monitor/Criteria/CompareCriteria.js +3 -0
- package/build/dist/Server/Utils/Monitor/Criteria/CompareCriteria.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/EvaluateOverTime.js +9 -8
- package/build/dist/Server/Utils/Monitor/Criteria/EvaluateOverTime.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorIncident.js +0 -1
- package/build/dist/Server/Utils/Monitor/MonitorIncident.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorResource.js +164 -98
- package/build/dist/Server/Utils/Monitor/MonitorResource.js.map +1 -1
- package/build/dist/Server/Utils/Telemetry/Telemetry.js +100 -0
- package/build/dist/Server/Utils/Telemetry/Telemetry.js.map +1 -0
- package/build/dist/Types/Html.js +8 -0
- package/build/dist/Types/Html.js.map +1 -1
- package/build/dist/Types/Monitor/CriteriaFilter.js +0 -29
- package/build/dist/Types/Monitor/CriteriaFilter.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorMetricType.js +12 -0
- package/build/dist/Types/Monitor/MonitorMetricType.js.map +1 -0
- package/build/dist/Types/Monitor/MonitorType.js +14 -0
- package/build/dist/Types/Monitor/MonitorType.js.map +1 -1
- package/build/dist/UI/Components/Charts/ChartGroup/ChartGroup.js +1 -1
- package/build/dist/UI/Components/Charts/ChartLibrary/LineChart/LineChart.js +1 -1
- package/build/dist/UI/Components/Charts/Line/LineChart.js +1 -1
- package/build/dist/UI/Components/ModelTable/TableView.js +1 -1
- package/build/dist/UI/Components/ModelTable/TableView.js.map +1 -1
- package/build/dist/UI/Components/MoreMenu/MoreMenuItem.js +1 -1
- package/build/dist/UI/Components/MoreMenu/MoreMenuItem.js.map +1 -1
- package/build/dist/Utils/Monitor/MonitorMetricType.js +118 -0
- package/build/dist/Utils/Monitor/MonitorMetricType.js.map +1 -0
- package/package.json +3 -2
- package/Models/AnalyticsModels/MonitorMetricsByMinute.ts +0 -177
- package/Server/Services/MonitorMetricsByMinuteService.ts +0 -14
- package/build/dist/Models/AnalyticsModels/MonitorMetricsByMinute.js +0 -149
- package/build/dist/Models/AnalyticsModels/MonitorMetricsByMinute.js.map +0 -1
- package/build/dist/Server/Services/MonitorMetricsByMinuteService.js +0 -12
- package/build/dist/Server/Services/MonitorMetricsByMinuteService.js.map +0 -1
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import MonitorMetricsByMinuteService from "../../../Services/MonitorMetricsByMinuteService";
|
|
2
1
|
import Query from "../../../Types/AnalyticsDatabase/Query";
|
|
3
2
|
import GreaterThanOrEqual from "Common/Types/BaseDatabase/GreaterThanOrEqual";
|
|
4
3
|
import { LIMIT_PER_PROJECT } from "Common/Types/Database/LimitMax";
|
|
@@ -10,7 +9,9 @@ import {
|
|
|
10
9
|
EvaluateOverTimeType,
|
|
11
10
|
} from "Common/Types/Monitor/CriteriaFilter";
|
|
12
11
|
import ObjectID from "Common/Types/ObjectID";
|
|
13
|
-
import
|
|
12
|
+
import Metric from "../../../../Models/AnalyticsModels/Metric";
|
|
13
|
+
import MonitorMetricTypeUtil from "../../../../Utils/Monitor/MonitorMetricType";
|
|
14
|
+
import MetricService from "../../../Services/MetricService";
|
|
14
15
|
|
|
15
16
|
export default class EvaluateOverTime {
|
|
16
17
|
public static async getValueOverTime(data: {
|
|
@@ -27,36 +28,35 @@ export default class EvaluateOverTime {
|
|
|
27
28
|
|
|
28
29
|
// TODO: Query over miscData
|
|
29
30
|
|
|
30
|
-
const query: Query<
|
|
31
|
+
const query: Query<Metric> = {
|
|
31
32
|
createdAt: new GreaterThanOrEqual(lastMinutesDate),
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
serviceId: data.monitorId,
|
|
34
|
+
name: MonitorMetricTypeUtil.getMonitorMeticTypeByCheckOn(data.metricType),
|
|
34
35
|
};
|
|
35
36
|
|
|
36
37
|
if (data.miscData) {
|
|
37
|
-
query.
|
|
38
|
+
query.attributes = data.miscData;
|
|
38
39
|
}
|
|
39
40
|
|
|
40
|
-
const monitorMetricsItems: Array<
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
});
|
|
41
|
+
const monitorMetricsItems: Array<Metric> = await MetricService.findBy({
|
|
42
|
+
query: query,
|
|
43
|
+
limit: LIMIT_PER_PROJECT,
|
|
44
|
+
skip: 0,
|
|
45
|
+
props: {
|
|
46
|
+
isRoot: true,
|
|
47
|
+
},
|
|
48
|
+
select: {
|
|
49
|
+
value: true,
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
52
|
|
|
53
53
|
const values: Array<number | boolean> = monitorMetricsItems
|
|
54
|
-
.map((item:
|
|
54
|
+
.map((item: Metric) => {
|
|
55
55
|
if (data.metricType === CheckOn.IsOnline) {
|
|
56
|
-
return item.
|
|
56
|
+
return item.value === 1;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
return item.
|
|
59
|
+
return item.value;
|
|
60
60
|
})
|
|
61
61
|
.filter((value: number | boolean | undefined) => {
|
|
62
62
|
return value !== undefined;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import MonitorMetricsByMinuteService from "../../Services/MonitorMetricsByMinuteService";
|
|
2
1
|
import MonitorProbeService from "../../Services/MonitorProbeService";
|
|
3
2
|
import MonitorService from "../../Services/MonitorService";
|
|
4
3
|
import MonitorStatusTimelineService from "../../Services/MonitorStatusTimelineService";
|
|
@@ -22,7 +21,6 @@ import {
|
|
|
22
21
|
CriteriaFilter,
|
|
23
22
|
FilterCondition,
|
|
24
23
|
} from "Common/Types/Monitor/CriteriaFilter";
|
|
25
|
-
import CustomCodeMonitorResponse from "Common/Types/Monitor/CustomCodeMonitor/CustomCodeMonitorResponse";
|
|
26
24
|
import IncomingMonitorRequest from "Common/Types/Monitor/IncomingMonitor/IncomingMonitorRequest";
|
|
27
25
|
import MonitorCriteria from "Common/Types/Monitor/MonitorCriteria";
|
|
28
26
|
import MonitorCriteriaInstance from "Common/Types/Monitor/MonitorCriteriaInstance";
|
|
@@ -36,7 +34,6 @@ import ObjectID from "Common/Types/ObjectID";
|
|
|
36
34
|
import ProbeApiIngestResponse from "Common/Types/Probe/ProbeApiIngestResponse";
|
|
37
35
|
import ProbeMonitorResponse from "Common/Types/Probe/ProbeMonitorResponse";
|
|
38
36
|
import Typeof from "Common/Types/Typeof";
|
|
39
|
-
import MonitorMetricsByMinute from "Common/Models/AnalyticsModels/MonitorMetricsByMinute";
|
|
40
37
|
import Monitor from "Common/Models/DatabaseModels/Monitor";
|
|
41
38
|
import MonitorProbe from "Common/Models/DatabaseModels/MonitorProbe";
|
|
42
39
|
import MonitorStatusTimeline from "Common/Models/DatabaseModels/MonitorStatusTimeline";
|
|
@@ -51,6 +48,13 @@ import MonitorIncident from "./MonitorIncident";
|
|
|
51
48
|
import MonitorAlert from "./MonitorAlert";
|
|
52
49
|
import MonitorStatusTimelineUtil from "./MonitorStatusTimeline";
|
|
53
50
|
import Semaphore, { SemaphoreMutex } from "../../Infrastructure/Semaphore";
|
|
51
|
+
import Metric, {
|
|
52
|
+
MetricPointType,
|
|
53
|
+
ServiceType,
|
|
54
|
+
} from "../../../Models/AnalyticsModels/Metric";
|
|
55
|
+
import MetricService from "../../Services/MetricService";
|
|
56
|
+
import MonitorMetricType from "../../../Types/Monitor/MonitorMetricType";
|
|
57
|
+
import TelemetryUtil from "../Telemetry/Telemetry";
|
|
54
58
|
|
|
55
59
|
export default class MonitorResourceUtil {
|
|
56
60
|
public static async monitorResource(
|
|
@@ -573,7 +577,7 @@ export default class MonitorResourceUtil {
|
|
|
573
577
|
return;
|
|
574
578
|
}
|
|
575
579
|
|
|
576
|
-
const itemsToSave: Array<
|
|
580
|
+
const itemsToSave: Array<Metric> = [];
|
|
577
581
|
|
|
578
582
|
if (
|
|
579
583
|
(data.dataToProcess as ServerMonitorResponse).basicInfrastructureMetrics
|
|
@@ -593,15 +597,25 @@ export default class MonitorResourceUtil {
|
|
|
593
597
|
isOnline = false;
|
|
594
598
|
}
|
|
595
599
|
|
|
596
|
-
const
|
|
597
|
-
|
|
600
|
+
const monitorMetric: Metric = new Metric();
|
|
601
|
+
|
|
602
|
+
monitorMetric.projectId = data.projectId;
|
|
603
|
+
monitorMetric.serviceId = data.monitorId;
|
|
604
|
+
monitorMetric.serviceType = ServiceType.Monitor;
|
|
605
|
+
monitorMetric.name = MonitorMetricType.IsOnline;
|
|
606
|
+
monitorMetric.description = CheckOn.IsOnline + " status for monitor";
|
|
607
|
+
monitorMetric.value = isOnline ? 1 : 0;
|
|
608
|
+
monitorMetric.unit = "";
|
|
609
|
+
monitorMetric.attributes = {
|
|
610
|
+
monitorId: data.monitorId.toString(),
|
|
611
|
+
projectId: data.projectId.toString(),
|
|
612
|
+
};
|
|
598
613
|
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
monitorMetricsByMinute.metricValue = isOnline ? 1 : 0;
|
|
614
|
+
monitorMetric.time = OneUptimeDate.getCurrentDate();
|
|
615
|
+
monitorMetric.timeUnixNano = OneUptimeDate.getCurrentDateAsUnixNano();
|
|
616
|
+
monitorMetric.metricPointType = MetricPointType.Sum;
|
|
603
617
|
|
|
604
|
-
itemsToSave.push(
|
|
618
|
+
itemsToSave.push(monitorMetric);
|
|
605
619
|
}
|
|
606
620
|
|
|
607
621
|
const basicMetrics: BasicInfrastructureMetrics | undefined = (
|
|
@@ -613,42 +627,73 @@ export default class MonitorResourceUtil {
|
|
|
613
627
|
}
|
|
614
628
|
|
|
615
629
|
if (basicMetrics.cpuMetrics) {
|
|
616
|
-
const
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
630
|
+
const monitorMetric: Metric = new Metric();
|
|
631
|
+
|
|
632
|
+
monitorMetric.projectId = data.projectId;
|
|
633
|
+
monitorMetric.serviceId = data.monitorId;
|
|
634
|
+
monitorMetric.serviceType = ServiceType.Monitor;
|
|
635
|
+
monitorMetric.name = MonitorMetricType.CPUUsagePercent;
|
|
636
|
+
monitorMetric.description = CheckOn.CPUUsagePercent + " of Server/VM";
|
|
637
|
+
monitorMetric.value = basicMetrics.cpuMetrics.percentUsed;
|
|
638
|
+
monitorMetric.unit = "%";
|
|
639
|
+
monitorMetric.attributes = {
|
|
640
|
+
monitorId: data.monitorId.toString(),
|
|
641
|
+
projectId: data.projectId.toString(),
|
|
642
|
+
};
|
|
643
|
+
|
|
644
|
+
monitorMetric.time = OneUptimeDate.getCurrentDate();
|
|
645
|
+
monitorMetric.timeUnixNano = OneUptimeDate.getCurrentDateAsUnixNano();
|
|
646
|
+
monitorMetric.metricPointType = MetricPointType.Sum;
|
|
647
|
+
|
|
648
|
+
itemsToSave.push(monitorMetric);
|
|
625
649
|
}
|
|
626
650
|
|
|
627
651
|
if (basicMetrics.memoryMetrics) {
|
|
628
|
-
const
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
652
|
+
const monitorMetric: Metric = new Metric();
|
|
653
|
+
|
|
654
|
+
monitorMetric.projectId = data.projectId;
|
|
655
|
+
monitorMetric.serviceId = data.monitorId;
|
|
656
|
+
monitorMetric.serviceType = ServiceType.Monitor;
|
|
657
|
+
monitorMetric.name = MonitorMetricType.MemoryUsagePercent;
|
|
658
|
+
monitorMetric.description =
|
|
659
|
+
CheckOn.MemoryUsagePercent + " of Server/VM";
|
|
660
|
+
monitorMetric.value = basicMetrics.memoryMetrics.percentUsed;
|
|
661
|
+
monitorMetric.unit = "%";
|
|
662
|
+
monitorMetric.attributes = {
|
|
663
|
+
monitorId: data.monitorId.toString(),
|
|
664
|
+
projectId: data.projectId.toString(),
|
|
665
|
+
};
|
|
666
|
+
|
|
667
|
+
monitorMetric.time = OneUptimeDate.getCurrentDate();
|
|
668
|
+
monitorMetric.timeUnixNano = OneUptimeDate.getCurrentDateAsUnixNano();
|
|
669
|
+
monitorMetric.metricPointType = MetricPointType.Sum;
|
|
670
|
+
|
|
671
|
+
itemsToSave.push(monitorMetric);
|
|
637
672
|
}
|
|
638
673
|
|
|
639
674
|
if (basicMetrics.diskMetrics && basicMetrics.diskMetrics.length > 0) {
|
|
640
675
|
for (const diskMetric of basicMetrics.diskMetrics) {
|
|
641
|
-
const
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
676
|
+
const monitorMetric: Metric = new Metric();
|
|
677
|
+
|
|
678
|
+
monitorMetric.projectId = data.projectId;
|
|
679
|
+
monitorMetric.serviceId = data.monitorId;
|
|
680
|
+
monitorMetric.serviceType = ServiceType.Monitor;
|
|
681
|
+
monitorMetric.name = MonitorMetricType.DiskUsagePercent;
|
|
682
|
+
monitorMetric.description =
|
|
683
|
+
CheckOn.DiskUsagePercent + " of Server/VM";
|
|
684
|
+
monitorMetric.value = diskMetric.percentUsed;
|
|
685
|
+
monitorMetric.unit = "%";
|
|
686
|
+
monitorMetric.attributes = {
|
|
687
|
+
monitorId: data.monitorId.toString(),
|
|
688
|
+
projectId: data.projectId.toString(),
|
|
648
689
|
diskPath: diskMetric.diskPath,
|
|
649
690
|
};
|
|
650
691
|
|
|
651
|
-
|
|
692
|
+
monitorMetric.time = OneUptimeDate.getCurrentDate();
|
|
693
|
+
monitorMetric.timeUnixNano = OneUptimeDate.getCurrentDateAsUnixNano();
|
|
694
|
+
monitorMetric.metricPointType = MetricPointType.Sum;
|
|
695
|
+
|
|
696
|
+
itemsToSave.push(monitorMetric);
|
|
652
697
|
}
|
|
653
698
|
}
|
|
654
699
|
}
|
|
@@ -657,21 +702,30 @@ export default class MonitorResourceUtil {
|
|
|
657
702
|
(data.dataToProcess as ProbeMonitorResponse).customCodeMonitorResponse
|
|
658
703
|
?.executionTimeInMS
|
|
659
704
|
) {
|
|
660
|
-
const
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
705
|
+
const monitorMetric: Metric = new Metric();
|
|
706
|
+
|
|
707
|
+
monitorMetric.projectId = data.projectId;
|
|
708
|
+
monitorMetric.serviceId = data.monitorId;
|
|
709
|
+
monitorMetric.serviceType = ServiceType.Monitor;
|
|
710
|
+
monitorMetric.name = MonitorMetricType.ExecutionTime;
|
|
711
|
+
monitorMetric.description = CheckOn.ExecutionTime + " of this monitor";
|
|
712
|
+
monitorMetric.value = (
|
|
666
713
|
data.dataToProcess as ProbeMonitorResponse
|
|
667
714
|
).customCodeMonitorResponse?.executionTimeInMS;
|
|
668
|
-
|
|
715
|
+
monitorMetric.unit = "ms";
|
|
716
|
+
monitorMetric.attributes = {
|
|
717
|
+
monitorId: data.monitorId.toString(),
|
|
718
|
+
projectId: data.projectId.toString(),
|
|
669
719
|
probeId: (
|
|
670
720
|
data.dataToProcess as ProbeMonitorResponse
|
|
671
721
|
).probeId.toString(),
|
|
672
722
|
};
|
|
673
723
|
|
|
674
|
-
|
|
724
|
+
monitorMetric.time = OneUptimeDate.getCurrentDate();
|
|
725
|
+
monitorMetric.timeUnixNano = OneUptimeDate.getCurrentDateAsUnixNano();
|
|
726
|
+
monitorMetric.metricPointType = MetricPointType.Sum;
|
|
727
|
+
|
|
728
|
+
itemsToSave.push(monitorMetric);
|
|
675
729
|
}
|
|
676
730
|
|
|
677
731
|
if (
|
|
@@ -685,14 +739,18 @@ export default class MonitorResourceUtil {
|
|
|
685
739
|
for (const syntheticMonitorResponse of (
|
|
686
740
|
data.dataToProcess as ProbeMonitorResponse
|
|
687
741
|
).syntheticMonitorResponse || []) {
|
|
688
|
-
const
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
742
|
+
const monitorMetric: Metric = new Metric();
|
|
743
|
+
|
|
744
|
+
monitorMetric.projectId = data.projectId;
|
|
745
|
+
monitorMetric.serviceId = data.monitorId;
|
|
746
|
+
monitorMetric.serviceType = ServiceType.Monitor;
|
|
747
|
+
monitorMetric.name = MonitorMetricType.ExecutionTime;
|
|
748
|
+
monitorMetric.description = CheckOn.ExecutionTime + " of this monitor";
|
|
749
|
+
monitorMetric.value = syntheticMonitorResponse.executionTimeInMS;
|
|
750
|
+
monitorMetric.unit = "ms";
|
|
751
|
+
monitorMetric.attributes = {
|
|
752
|
+
monitorId: data.monitorId.toString(),
|
|
753
|
+
projectId: data.projectId.toString(),
|
|
696
754
|
probeId: (
|
|
697
755
|
data.dataToProcess as ProbeMonitorResponse
|
|
698
756
|
).probeId.toString(),
|
|
@@ -700,118 +758,119 @@ export default class MonitorResourceUtil {
|
|
|
700
758
|
screenSizeType: syntheticMonitorResponse.screenSizeType,
|
|
701
759
|
};
|
|
702
760
|
|
|
703
|
-
|
|
761
|
+
monitorMetric.time = OneUptimeDate.getCurrentDate();
|
|
762
|
+
monitorMetric.timeUnixNano = OneUptimeDate.getCurrentDateAsUnixNano();
|
|
763
|
+
monitorMetric.metricPointType = MetricPointType.Sum;
|
|
764
|
+
|
|
765
|
+
itemsToSave.push(monitorMetric);
|
|
704
766
|
}
|
|
705
767
|
}
|
|
706
768
|
|
|
707
769
|
if ((data.dataToProcess as ProbeMonitorResponse).responseTimeInMs) {
|
|
708
|
-
const
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
770
|
+
const monitorMetric: Metric = new Metric();
|
|
771
|
+
|
|
772
|
+
monitorMetric.projectId = data.projectId;
|
|
773
|
+
monitorMetric.serviceId = data.monitorId;
|
|
774
|
+
monitorMetric.serviceType = ServiceType.Monitor;
|
|
775
|
+
monitorMetric.name = MonitorMetricType.ResponseTime;
|
|
776
|
+
monitorMetric.description = CheckOn.ResponseTime + " of this monitor";
|
|
777
|
+
monitorMetric.value = (
|
|
714
778
|
data.dataToProcess as ProbeMonitorResponse
|
|
715
779
|
).responseTimeInMs;
|
|
716
|
-
|
|
780
|
+
monitorMetric.unit = "ms";
|
|
781
|
+
monitorMetric.attributes = {
|
|
782
|
+
monitorId: data.monitorId.toString(),
|
|
783
|
+
projectId: data.projectId.toString(),
|
|
717
784
|
probeId: (
|
|
718
785
|
data.dataToProcess as ProbeMonitorResponse
|
|
719
786
|
).probeId.toString(),
|
|
720
787
|
};
|
|
721
788
|
|
|
722
|
-
|
|
789
|
+
monitorMetric.time = OneUptimeDate.getCurrentDate();
|
|
790
|
+
monitorMetric.timeUnixNano = OneUptimeDate.getCurrentDateAsUnixNano();
|
|
791
|
+
monitorMetric.metricPointType = MetricPointType.Sum;
|
|
792
|
+
|
|
793
|
+
itemsToSave.push(monitorMetric);
|
|
723
794
|
}
|
|
724
795
|
|
|
725
796
|
if ((data.dataToProcess as ProbeMonitorResponse).isOnline !== undefined) {
|
|
726
|
-
const
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
797
|
+
const monitorMetric: Metric = new Metric();
|
|
798
|
+
|
|
799
|
+
monitorMetric.projectId = data.projectId;
|
|
800
|
+
monitorMetric.serviceId = data.monitorId;
|
|
801
|
+
monitorMetric.serviceType = ServiceType.Monitor;
|
|
802
|
+
monitorMetric.name = MonitorMetricType.IsOnline;
|
|
803
|
+
monitorMetric.description = CheckOn.IsOnline + " status for monitor";
|
|
804
|
+
monitorMetric.value = (data.dataToProcess as ProbeMonitorResponse)
|
|
805
|
+
.isOnline
|
|
806
|
+
? 1
|
|
807
|
+
: 0;
|
|
808
|
+
monitorMetric.unit = "";
|
|
809
|
+
monitorMetric.attributes = {
|
|
810
|
+
monitorId: data.monitorId.toString(),
|
|
811
|
+
projectId: data.projectId.toString(),
|
|
733
812
|
probeId: (
|
|
734
813
|
data.dataToProcess as ProbeMonitorResponse
|
|
735
814
|
).probeId.toString(),
|
|
736
815
|
};
|
|
737
816
|
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
817
|
+
monitorMetric.time = OneUptimeDate.getCurrentDate();
|
|
818
|
+
monitorMetric.timeUnixNano = OneUptimeDate.getCurrentDateAsUnixNano();
|
|
819
|
+
monitorMetric.metricPointType = MetricPointType.Sum;
|
|
741
820
|
|
|
742
|
-
itemsToSave.push(
|
|
821
|
+
itemsToSave.push(monitorMetric);
|
|
743
822
|
}
|
|
744
823
|
|
|
745
824
|
if ((data.dataToProcess as ProbeMonitorResponse).responseCode) {
|
|
746
|
-
const
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
825
|
+
const monitorMetric: Metric = new Metric();
|
|
826
|
+
|
|
827
|
+
monitorMetric.projectId = data.projectId;
|
|
828
|
+
monitorMetric.serviceId = data.monitorId;
|
|
829
|
+
monitorMetric.serviceType = ServiceType.Monitor;
|
|
830
|
+
monitorMetric.name = MonitorMetricType.ResponseStatusCode;
|
|
831
|
+
monitorMetric.description =
|
|
832
|
+
CheckOn.ResponseStatusCode + " for this monitor";
|
|
833
|
+
monitorMetric.value = (
|
|
752
834
|
data.dataToProcess as ProbeMonitorResponse
|
|
753
835
|
).responseCode;
|
|
754
|
-
|
|
836
|
+
monitorMetric.unit = "Status Code";
|
|
837
|
+
monitorMetric.attributes = {
|
|
838
|
+
monitorId: data.monitorId.toString(),
|
|
839
|
+
projectId: data.projectId.toString(),
|
|
755
840
|
probeId: (
|
|
756
841
|
data.dataToProcess as ProbeMonitorResponse
|
|
757
842
|
).probeId.toString(),
|
|
758
843
|
};
|
|
759
844
|
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
if ((data.dataToProcess as ProbeMonitorResponse).syntheticMonitorResponse) {
|
|
764
|
-
for (const syntheticMonitorResponse of (
|
|
765
|
-
data.dataToProcess as ProbeMonitorResponse
|
|
766
|
-
).syntheticMonitorResponse || []) {
|
|
767
|
-
const monitorMetricsByMinute: MonitorMetricsByMinute =
|
|
768
|
-
new MonitorMetricsByMinute();
|
|
769
|
-
monitorMetricsByMinute.monitorId = data.monitorId;
|
|
770
|
-
monitorMetricsByMinute.projectId = data.projectId;
|
|
771
|
-
monitorMetricsByMinute.metricType = CheckOn.ExecutionTime;
|
|
772
|
-
monitorMetricsByMinute.metricValue =
|
|
773
|
-
syntheticMonitorResponse.executionTimeInMS;
|
|
774
|
-
monitorMetricsByMinute.miscData = {
|
|
775
|
-
probeId: (
|
|
776
|
-
data.dataToProcess as ProbeMonitorResponse
|
|
777
|
-
).probeId.toString(),
|
|
778
|
-
browserType: syntheticMonitorResponse.browserType,
|
|
779
|
-
screenSizeType: syntheticMonitorResponse.screenSizeType,
|
|
780
|
-
};
|
|
781
|
-
|
|
782
|
-
itemsToSave.push(monitorMetricsByMinute);
|
|
783
|
-
}
|
|
784
|
-
}
|
|
845
|
+
monitorMetric.time = OneUptimeDate.getCurrentDate();
|
|
846
|
+
monitorMetric.timeUnixNano = OneUptimeDate.getCurrentDateAsUnixNano();
|
|
847
|
+
monitorMetric.metricPointType = MetricPointType.Sum;
|
|
785
848
|
|
|
786
|
-
|
|
787
|
-
(data.dataToProcess as ProbeMonitorResponse).customCodeMonitorResponse
|
|
788
|
-
) {
|
|
789
|
-
const customCodeMonitorResponse: CustomCodeMonitorResponse = (
|
|
790
|
-
data.dataToProcess as ProbeMonitorResponse
|
|
791
|
-
).customCodeMonitorResponse!;
|
|
792
|
-
|
|
793
|
-
const monitorMetricsByMinute: MonitorMetricsByMinute =
|
|
794
|
-
new MonitorMetricsByMinute();
|
|
795
|
-
monitorMetricsByMinute.monitorId = data.monitorId;
|
|
796
|
-
monitorMetricsByMinute.projectId = data.projectId;
|
|
797
|
-
monitorMetricsByMinute.metricType = CheckOn.ExecutionTime;
|
|
798
|
-
monitorMetricsByMinute.metricValue =
|
|
799
|
-
customCodeMonitorResponse.executionTimeInMS;
|
|
800
|
-
monitorMetricsByMinute.miscData = {
|
|
801
|
-
probeId: (
|
|
802
|
-
data.dataToProcess as ProbeMonitorResponse
|
|
803
|
-
).probeId.toString(),
|
|
804
|
-
};
|
|
805
|
-
|
|
806
|
-
itemsToSave.push(monitorMetricsByMinute);
|
|
849
|
+
itemsToSave.push(monitorMetric);
|
|
807
850
|
}
|
|
808
851
|
|
|
809
|
-
await
|
|
852
|
+
await MetricService.createMany({
|
|
810
853
|
items: itemsToSave,
|
|
811
854
|
props: {
|
|
812
855
|
isRoot: true,
|
|
813
856
|
},
|
|
814
857
|
});
|
|
858
|
+
|
|
859
|
+
// index attributes.
|
|
860
|
+
TelemetryUtil.indexAttributes({
|
|
861
|
+
attributes: [
|
|
862
|
+
"monitorId",
|
|
863
|
+
"projectId",
|
|
864
|
+
"probeId",
|
|
865
|
+
"browserType",
|
|
866
|
+
"screenSizeType",
|
|
867
|
+
"diskPath",
|
|
868
|
+
],
|
|
869
|
+
projectId: data.projectId,
|
|
870
|
+
telemetryType: TelemetryType.Metric,
|
|
871
|
+
}).catch((err: Error) => {
|
|
872
|
+
logger.error(err);
|
|
873
|
+
});
|
|
815
874
|
}
|
|
816
875
|
|
|
817
876
|
private static async processMonitorStep(input: {
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { JSONArray, JSONObject, JSONValue } from "../../../Types/JSON";
|
|
2
|
+
import JSONFunctions from "../../../Types/JSONFunctions";
|
|
3
|
+
import ObjectID from "../../../Types/ObjectID";
|
|
4
|
+
import TelemetryType from "../../../Types/Telemetry/TelemetryType";
|
|
5
|
+
import ArrayUtil from "../../../Utils/Array";
|
|
6
|
+
import GlobalCache from "../../Infrastructure/GlobalCache";
|
|
7
|
+
import TelemetryAttributeService from "../../Services/TelemetryAttributeService";
|
|
8
|
+
|
|
9
|
+
export default class TelemetryUtil {
|
|
10
|
+
public static async indexAttributes(data: {
|
|
11
|
+
attributes: string[];
|
|
12
|
+
projectId: ObjectID;
|
|
13
|
+
telemetryType: TelemetryType;
|
|
14
|
+
}): Promise<void> {
|
|
15
|
+
// index attributes
|
|
16
|
+
|
|
17
|
+
const cacheKey: string =
|
|
18
|
+
data.projectId.toString() + "_" + data.telemetryType;
|
|
19
|
+
|
|
20
|
+
// get keys from cache
|
|
21
|
+
const cacheKeys: string[] =
|
|
22
|
+
(await GlobalCache.getStringArray("telemetryAttributesKeys", cacheKey)) ||
|
|
23
|
+
[];
|
|
24
|
+
|
|
25
|
+
let isKeysMissingInCache: boolean = false;
|
|
26
|
+
|
|
27
|
+
// check if keys are missing in cache
|
|
28
|
+
|
|
29
|
+
for (const key of data.attributes) {
|
|
30
|
+
if (!cacheKeys.includes(key)) {
|
|
31
|
+
isKeysMissingInCache = true;
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// merge keys and remove duplicates
|
|
37
|
+
if (isKeysMissingInCache) {
|
|
38
|
+
const dbKeys: string[] = await TelemetryAttributeService.fetchAttributes({
|
|
39
|
+
projectId: data.projectId,
|
|
40
|
+
telemetryType: data.telemetryType,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const mergedKeys: Array<string> = ArrayUtil.removeDuplicates([
|
|
44
|
+
...dbKeys,
|
|
45
|
+
...data.attributes,
|
|
46
|
+
...cacheKeys,
|
|
47
|
+
]);
|
|
48
|
+
|
|
49
|
+
await GlobalCache.setStringArray(
|
|
50
|
+
"telemetryAttributesKeys",
|
|
51
|
+
cacheKey,
|
|
52
|
+
mergedKeys,
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
await TelemetryAttributeService.refreshAttributes({
|
|
56
|
+
projectId: data.projectId,
|
|
57
|
+
telemetryType: data.telemetryType,
|
|
58
|
+
attributes: mergedKeys,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public static getAttributes(data: {
|
|
64
|
+
items: JSONArray;
|
|
65
|
+
telemetryServiceId?: ObjectID;
|
|
66
|
+
telemetryServiceName?: string;
|
|
67
|
+
}): JSONObject {
|
|
68
|
+
const { items } = data;
|
|
69
|
+
|
|
70
|
+
const finalObj: JSONObject = {};
|
|
71
|
+
// We need to convert this to date.
|
|
72
|
+
const attributes: JSONArray = items;
|
|
73
|
+
|
|
74
|
+
type GetValueFunction = (value: JSONValue) => JSONValue;
|
|
75
|
+
|
|
76
|
+
const getValue: GetValueFunction = (value: JSONValue): JSONValue => {
|
|
77
|
+
value = value as JSONObject;
|
|
78
|
+
|
|
79
|
+
if (value["stringValue"]) {
|
|
80
|
+
value = value["stringValue"] as string;
|
|
81
|
+
} else if (value["intValue"]) {
|
|
82
|
+
value = value["intValue"] as number;
|
|
83
|
+
} else if (value["doubleValue"]) {
|
|
84
|
+
value = value["doubleValue"] as number;
|
|
85
|
+
} else if (value["boolValue"]) {
|
|
86
|
+
value = value["boolValue"] as boolean;
|
|
87
|
+
} else if (
|
|
88
|
+
value["arrayValue"] &&
|
|
89
|
+
(value["arrayValue"] as JSONObject)["values"]
|
|
90
|
+
) {
|
|
91
|
+
value = (
|
|
92
|
+
(value["arrayValue"] as JSONObject)["values"] as JSONArray
|
|
93
|
+
).map((v: JSONObject) => {
|
|
94
|
+
return getValue(v);
|
|
95
|
+
});
|
|
96
|
+
} else if (
|
|
97
|
+
value["mapValue"] &&
|
|
98
|
+
(value["mapValue"] as JSONObject)["fields"]
|
|
99
|
+
) {
|
|
100
|
+
value = getValue((value["mapValue"] as JSONObject)["fields"]);
|
|
101
|
+
} else if (value["nullValue"]) {
|
|
102
|
+
value = null;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return value;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
if (attributes) {
|
|
109
|
+
for (const attribute of attributes) {
|
|
110
|
+
if (attribute["key"] && typeof attribute["key"] === "string") {
|
|
111
|
+
const value: JSONValue = getValue(attribute["value"]);
|
|
112
|
+
finalObj[attribute["key"]] = value;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// add oneuptime specific attributes
|
|
118
|
+
if (!finalObj["oneuptime"]) {
|
|
119
|
+
finalObj["oneuptime"] = {};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (!(finalObj["oneuptime"] as JSONObject)["telemetry"]) {
|
|
123
|
+
(finalObj["oneuptime"] as JSONObject)["telemetry"] = {};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (
|
|
127
|
+
!((finalObj["oneuptime"] as JSONObject)["telemetry"] as JSONObject)[
|
|
128
|
+
"service"
|
|
129
|
+
]
|
|
130
|
+
) {
|
|
131
|
+
((finalObj["oneuptime"] as JSONObject)["telemetry"] as JSONObject)[
|
|
132
|
+
"service"
|
|
133
|
+
] = {};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (data.telemetryServiceId) {
|
|
137
|
+
(
|
|
138
|
+
((finalObj["oneuptime"] as JSONObject)["telemetry"] as JSONObject)[
|
|
139
|
+
"service"
|
|
140
|
+
] as JSONObject
|
|
141
|
+
)["id"] = data.telemetryServiceId.toString();
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (data.telemetryServiceName) {
|
|
145
|
+
(
|
|
146
|
+
((finalObj["oneuptime"] as JSONObject)["telemetry"] as JSONObject)[
|
|
147
|
+
"service"
|
|
148
|
+
] as JSONObject
|
|
149
|
+
)["name"] = data.telemetryServiceName;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return JSONFunctions.flattenObject(finalObj);
|
|
153
|
+
}
|
|
154
|
+
}
|