@oneuptime/common 10.0.55 → 10.0.56
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/DatabaseModels/DockerHost.ts +662 -0
- package/Models/DatabaseModels/GlobalConfig.ts +112 -0
- package/Models/DatabaseModels/Index.ts +2 -0
- package/Server/API/TelemetryAPI.ts +352 -16
- package/Server/Infrastructure/ClickhouseConfig.ts +9 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1774000000002-MigrationName.ts +76 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1775766676723-MigrationName.ts +133 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1775900000000-AddGlobalSmtpOAuth.ts +51 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +6 -0
- package/Server/Services/DockerHostService.ts +173 -0
- package/Server/Services/ExceptionAggregationService.ts +335 -0
- package/Server/Services/Index.ts +2 -0
- package/Server/Services/LogAggregationService.ts +17 -0
- package/Server/Services/MonitorService.ts +21 -21
- package/Server/Services/TraceAggregationService.ts +514 -0
- package/Server/Utils/Monitor/MonitorCriteriaEvaluator.ts +73 -1
- package/Tests/Server/Services/LogAggregationService.test.ts +2 -2
- package/Tests/__mocks__/mermaid.js +18 -0
- package/Tests/__mocks__/react-markdown.js +17 -0
- package/Tests/__mocks__/react-syntax-highlighter.js +19 -0
- package/Tests/__mocks__/remark-gfm.js +8 -0
- package/Types/Icon/IconProp.ts +1 -0
- package/Types/Monitor/DockerAlertTemplates.ts +507 -0
- package/Types/Monitor/DockerMetricCatalog.ts +226 -0
- package/Types/Monitor/MonitorStep.ts +33 -0
- package/Types/Monitor/MonitorStepDockerMonitor.ts +38 -0
- package/Types/Monitor/MonitorType.ts +15 -1
- package/Types/Permission.ts +38 -0
- package/UI/Components/Icon/Icon.tsx +87 -0
- package/UI/Components/Markdown.tsx/MarkdownEditor.tsx +7 -132
- package/UI/Components/ModelDetail/CardModelDetail.tsx +11 -1
- package/UI/Components/TelemetryViewer/TelemetryViewer.tsx +285 -0
- package/UI/Components/TelemetryViewer/components/TelemetryActiveFilterChips.tsx +85 -0
- package/UI/Components/TelemetryViewer/components/TelemetryDetailPanel.tsx +156 -0
- package/UI/Components/TelemetryViewer/components/TelemetryFacetSection.tsx +160 -0
- package/UI/Components/TelemetryViewer/components/TelemetryFacetSidebar.tsx +85 -0
- package/UI/Components/TelemetryViewer/components/TelemetryFacetValueRow.tsx +102 -0
- package/UI/Components/TelemetryViewer/components/TelemetryHistogram.tsx +280 -0
- package/UI/Components/TelemetryViewer/components/TelemetryHistogramTooltip.tsx +125 -0
- package/UI/Components/TelemetryViewer/components/TelemetryPagination.tsx +114 -0
- package/UI/Components/TelemetryViewer/components/TelemetrySearchBar.tsx +378 -0
- package/UI/Components/TelemetryViewer/components/TelemetrySearchHelp.tsx +78 -0
- package/UI/Components/TelemetryViewer/components/TelemetrySearchSuggestions.tsx +64 -0
- package/UI/Components/TelemetryViewer/components/TelemetryTimeRangePicker.tsx +193 -0
- package/UI/Components/TelemetryViewer/types.ts +67 -0
- package/build/dist/Models/DatabaseModels/DockerHost.js +686 -0
- package/build/dist/Models/DatabaseModels/DockerHost.js.map +1 -0
- package/build/dist/Models/DatabaseModels/GlobalConfig.js +117 -0
- package/build/dist/Models/DatabaseModels/GlobalConfig.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Index.js +2 -0
- package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
- package/build/dist/Server/API/TelemetryAPI.js +237 -16
- package/build/dist/Server/API/TelemetryAPI.js.map +1 -1
- package/build/dist/Server/Infrastructure/ClickhouseConfig.js +9 -0
- package/build/dist/Server/Infrastructure/ClickhouseConfig.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774000000002-MigrationName.js +35 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774000000002-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1775766676723-MigrationName.js +52 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1775766676723-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1775900000000-AddGlobalSmtpOAuth.js +26 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1775900000000-AddGlobalSmtpOAuth.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +6 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Services/DockerHostService.js +162 -0
- package/build/dist/Server/Services/DockerHostService.js.map +1 -0
- package/build/dist/Server/Services/ExceptionAggregationService.js +224 -0
- package/build/dist/Server/Services/ExceptionAggregationService.js.map +1 -0
- package/build/dist/Server/Services/Index.js +2 -0
- package/build/dist/Server/Services/Index.js.map +1 -1
- package/build/dist/Server/Services/LogAggregationService.js +11 -0
- package/build/dist/Server/Services/LogAggregationService.js.map +1 -1
- package/build/dist/Server/Services/MonitorService.js +19 -17
- package/build/dist/Server/Services/MonitorService.js.map +1 -1
- package/build/dist/Server/Services/TraceAggregationService.js +364 -0
- package/build/dist/Server/Services/TraceAggregationService.js.map +1 -0
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js +46 -1
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js.map +1 -1
- package/build/dist/Tests/Server/Services/LogAggregationService.test.js +2 -2
- package/build/dist/Tests/Server/Services/LogAggregationService.test.js.map +1 -1
- package/build/dist/Types/Icon/IconProp.js +1 -0
- package/build/dist/Types/Icon/IconProp.js.map +1 -1
- package/build/dist/Types/Monitor/DockerAlertTemplates.js +410 -0
- package/build/dist/Types/Monitor/DockerAlertTemplates.js.map +1 -0
- package/build/dist/Types/Monitor/DockerMetricCatalog.js +192 -0
- package/build/dist/Types/Monitor/DockerMetricCatalog.js.map +1 -0
- package/build/dist/Types/Monitor/MonitorStep.js +23 -0
- package/build/dist/Types/Monitor/MonitorStep.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorStepDockerMonitor.js +21 -0
- package/build/dist/Types/Monitor/MonitorStepDockerMonitor.js.map +1 -0
- package/build/dist/Types/Monitor/MonitorType.js +14 -1
- package/build/dist/Types/Monitor/MonitorType.js.map +1 -1
- package/build/dist/Types/Permission.js +36 -0
- package/build/dist/Types/Permission.js.map +1 -1
- package/build/dist/UI/Components/Icon/Icon.js +13 -0
- package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
- package/build/dist/UI/Components/Markdown.tsx/MarkdownEditor.js +7 -75
- package/build/dist/UI/Components/Markdown.tsx/MarkdownEditor.js.map +1 -1
- package/build/dist/UI/Components/ModelDetail/CardModelDetail.js +8 -1
- package/build/dist/UI/Components/ModelDetail/CardModelDetail.js.map +1 -1
- package/build/dist/UI/Components/TelemetryViewer/TelemetryViewer.js +71 -0
- package/build/dist/UI/Components/TelemetryViewer/TelemetryViewer.js.map +1 -0
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetryActiveFilterChips.js +39 -0
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetryActiveFilterChips.js.map +1 -0
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetryDetailPanel.js +61 -0
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetryDetailPanel.js.map +1 -0
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetryFacetSection.js +66 -0
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetryFacetSection.js.map +1 -0
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetryFacetSidebar.js +41 -0
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetryFacetSidebar.js.map +1 -0
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetryFacetValueRow.js +35 -0
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetryFacetValueRow.js.map +1 -0
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetryHistogram.js +132 -0
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetryHistogram.js.map +1 -0
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetryHistogramTooltip.js +65 -0
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetryHistogramTooltip.js.map +1 -0
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetryPagination.js +52 -0
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetryPagination.js.map +1 -0
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetrySearchBar.js +224 -0
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetrySearchBar.js.map +1 -0
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetrySearchHelp.js +35 -0
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetrySearchHelp.js.map +1 -0
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetrySearchSuggestions.js +27 -0
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetrySearchSuggestions.js.map +1 -0
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetryTimeRangePicker.js +97 -0
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetryTimeRangePicker.js.map +1 -0
- package/build/dist/UI/Components/TelemetryViewer/types.js +6 -0
- package/build/dist/UI/Components/TelemetryViewer/types.js.map +1 -0
- package/jest.config.json +6 -1
- package/package.json +1 -1
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
2
|
+
|
|
3
|
+
export class MigrationName1775766676723 implements MigrationInterface {
|
|
4
|
+
public name = "MigrationName1775766676723";
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(
|
|
8
|
+
`ALTER TABLE "DockerHost" DROP CONSTRAINT "FK_docker_host_projectId"`,
|
|
9
|
+
);
|
|
10
|
+
await queryRunner.query(
|
|
11
|
+
`ALTER TABLE "DockerHost" DROP CONSTRAINT "FK_docker_host_createdByUserId"`,
|
|
12
|
+
);
|
|
13
|
+
await queryRunner.query(
|
|
14
|
+
`ALTER TABLE "DockerHost" DROP CONSTRAINT "FK_docker_host_deletedByUserId"`,
|
|
15
|
+
);
|
|
16
|
+
await queryRunner.query(
|
|
17
|
+
`ALTER TABLE "DockerHostLabel" DROP CONSTRAINT "FK_docker_host_label_dockerHostId"`,
|
|
18
|
+
);
|
|
19
|
+
await queryRunner.query(
|
|
20
|
+
`ALTER TABLE "DockerHostLabel" DROP CONSTRAINT "FK_docker_host_label_labelId"`,
|
|
21
|
+
);
|
|
22
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_docker_host_projectId"`);
|
|
23
|
+
await queryRunner.query(
|
|
24
|
+
`DROP INDEX "public"."IDX_docker_host_hostIdentifier"`,
|
|
25
|
+
);
|
|
26
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_docker_host_slug"`);
|
|
27
|
+
await queryRunner.query(
|
|
28
|
+
`DROP INDEX "public"."IDX_docker_host_label_dockerHostId"`,
|
|
29
|
+
);
|
|
30
|
+
await queryRunner.query(
|
|
31
|
+
`DROP INDEX "public"."IDX_docker_host_label_labelId"`,
|
|
32
|
+
);
|
|
33
|
+
await queryRunner.query(
|
|
34
|
+
`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type":"Recurring","value":{"intervalType":"Day","intervalCount":{"_type":"PositiveNumber","value":1}}}'`,
|
|
35
|
+
);
|
|
36
|
+
await queryRunner.query(
|
|
37
|
+
`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type":"RestrictionTimes","value":{"restictionType":"None","dayRestrictionTimes":null,"weeklyRestrictionTimes":[]}}'`,
|
|
38
|
+
);
|
|
39
|
+
await queryRunner.query(
|
|
40
|
+
`CREATE INDEX "IDX_ae65515f6441c05aa0ed907ddf" ON "DockerHost" ("projectId") `,
|
|
41
|
+
);
|
|
42
|
+
await queryRunner.query(
|
|
43
|
+
`CREATE INDEX "IDX_52de5686db690e506374cd7378" ON "DockerHost" ("hostIdentifier") `,
|
|
44
|
+
);
|
|
45
|
+
await queryRunner.query(
|
|
46
|
+
`CREATE INDEX "IDX_ac05a97602df6aab28ceac1c8d" ON "DockerHostLabel" ("dockerHostId") `,
|
|
47
|
+
);
|
|
48
|
+
await queryRunner.query(
|
|
49
|
+
`CREATE INDEX "IDX_e19382fe2b139766b7d0176882" ON "DockerHostLabel" ("labelId") `,
|
|
50
|
+
);
|
|
51
|
+
await queryRunner.query(
|
|
52
|
+
`ALTER TABLE "DockerHost" ADD CONSTRAINT "FK_ae65515f6441c05aa0ed907ddf0" FOREIGN KEY ("projectId") REFERENCES "Project"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
53
|
+
);
|
|
54
|
+
await queryRunner.query(
|
|
55
|
+
`ALTER TABLE "DockerHost" ADD CONSTRAINT "FK_a9466fa226aeffe460e9134655a" FOREIGN KEY ("createdByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
|
|
56
|
+
);
|
|
57
|
+
await queryRunner.query(
|
|
58
|
+
`ALTER TABLE "DockerHost" ADD CONSTRAINT "FK_3f59ee567503d580023fd9195be" FOREIGN KEY ("deletedByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
|
|
59
|
+
);
|
|
60
|
+
await queryRunner.query(
|
|
61
|
+
`ALTER TABLE "DockerHostLabel" ADD CONSTRAINT "FK_ac05a97602df6aab28ceac1c8d3" FOREIGN KEY ("dockerHostId") REFERENCES "DockerHost"("_id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
|
62
|
+
);
|
|
63
|
+
await queryRunner.query(
|
|
64
|
+
`ALTER TABLE "DockerHostLabel" ADD CONSTRAINT "FK_e19382fe2b139766b7d01768824" FOREIGN KEY ("labelId") REFERENCES "Label"("_id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
69
|
+
await queryRunner.query(
|
|
70
|
+
`ALTER TABLE "DockerHostLabel" DROP CONSTRAINT "FK_e19382fe2b139766b7d01768824"`,
|
|
71
|
+
);
|
|
72
|
+
await queryRunner.query(
|
|
73
|
+
`ALTER TABLE "DockerHostLabel" DROP CONSTRAINT "FK_ac05a97602df6aab28ceac1c8d3"`,
|
|
74
|
+
);
|
|
75
|
+
await queryRunner.query(
|
|
76
|
+
`ALTER TABLE "DockerHost" DROP CONSTRAINT "FK_3f59ee567503d580023fd9195be"`,
|
|
77
|
+
);
|
|
78
|
+
await queryRunner.query(
|
|
79
|
+
`ALTER TABLE "DockerHost" DROP CONSTRAINT "FK_a9466fa226aeffe460e9134655a"`,
|
|
80
|
+
);
|
|
81
|
+
await queryRunner.query(
|
|
82
|
+
`ALTER TABLE "DockerHost" DROP CONSTRAINT "FK_ae65515f6441c05aa0ed907ddf0"`,
|
|
83
|
+
);
|
|
84
|
+
await queryRunner.query(
|
|
85
|
+
`DROP INDEX "public"."IDX_e19382fe2b139766b7d0176882"`,
|
|
86
|
+
);
|
|
87
|
+
await queryRunner.query(
|
|
88
|
+
`DROP INDEX "public"."IDX_ac05a97602df6aab28ceac1c8d"`,
|
|
89
|
+
);
|
|
90
|
+
await queryRunner.query(
|
|
91
|
+
`DROP INDEX "public"."IDX_52de5686db690e506374cd7378"`,
|
|
92
|
+
);
|
|
93
|
+
await queryRunner.query(
|
|
94
|
+
`DROP INDEX "public"."IDX_ae65515f6441c05aa0ed907ddf"`,
|
|
95
|
+
);
|
|
96
|
+
await queryRunner.query(
|
|
97
|
+
`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type": "RestrictionTimes", "value": {"restictionType": "None", "dayRestrictionTimes": null, "weeklyRestrictionTimes": []}}'`,
|
|
98
|
+
);
|
|
99
|
+
await queryRunner.query(
|
|
100
|
+
`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type": "Recurring", "value": {"intervalType": "Day", "intervalCount": {"_type": "PositiveNumber", "value": 1}}}'`,
|
|
101
|
+
);
|
|
102
|
+
await queryRunner.query(
|
|
103
|
+
`CREATE INDEX "IDX_docker_host_label_labelId" ON "DockerHostLabel" ("labelId") `,
|
|
104
|
+
);
|
|
105
|
+
await queryRunner.query(
|
|
106
|
+
`CREATE INDEX "IDX_docker_host_label_dockerHostId" ON "DockerHostLabel" ("dockerHostId") `,
|
|
107
|
+
);
|
|
108
|
+
await queryRunner.query(
|
|
109
|
+
`CREATE UNIQUE INDEX "IDX_docker_host_slug" ON "DockerHost" ("slug") `,
|
|
110
|
+
);
|
|
111
|
+
await queryRunner.query(
|
|
112
|
+
`CREATE INDEX "IDX_docker_host_hostIdentifier" ON "DockerHost" ("hostIdentifier") `,
|
|
113
|
+
);
|
|
114
|
+
await queryRunner.query(
|
|
115
|
+
`CREATE INDEX "IDX_docker_host_projectId" ON "DockerHost" ("projectId") `,
|
|
116
|
+
);
|
|
117
|
+
await queryRunner.query(
|
|
118
|
+
`ALTER TABLE "DockerHostLabel" ADD CONSTRAINT "FK_docker_host_label_labelId" FOREIGN KEY ("labelId") REFERENCES "Label"("_id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
|
119
|
+
);
|
|
120
|
+
await queryRunner.query(
|
|
121
|
+
`ALTER TABLE "DockerHostLabel" ADD CONSTRAINT "FK_docker_host_label_dockerHostId" FOREIGN KEY ("dockerHostId") REFERENCES "DockerHost"("_id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
|
122
|
+
);
|
|
123
|
+
await queryRunner.query(
|
|
124
|
+
`ALTER TABLE "DockerHost" ADD CONSTRAINT "FK_docker_host_deletedByUserId" FOREIGN KEY ("deletedByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
|
|
125
|
+
);
|
|
126
|
+
await queryRunner.query(
|
|
127
|
+
`ALTER TABLE "DockerHost" ADD CONSTRAINT "FK_docker_host_createdByUserId" FOREIGN KEY ("createdByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
|
|
128
|
+
);
|
|
129
|
+
await queryRunner.query(
|
|
130
|
+
`ALTER TABLE "DockerHost" ADD CONSTRAINT "FK_docker_host_projectId" FOREIGN KEY ("projectId") REFERENCES "Project"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
2
|
+
|
|
3
|
+
export class AddGlobalSmtpOAuth1775900000000 implements MigrationInterface {
|
|
4
|
+
public name = "AddGlobalSmtpOAuth1775900000000";
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
/*
|
|
8
|
+
* Add OAuth 2.0 columns to GlobalConfig table so global SMTP can be
|
|
9
|
+
* authenticated with providers like Microsoft 365 or Google Workspace.
|
|
10
|
+
*/
|
|
11
|
+
await queryRunner.query(
|
|
12
|
+
`ALTER TABLE "GlobalConfig" ADD "smtpAuthType" character varying(100) DEFAULT 'Username and Password'`,
|
|
13
|
+
);
|
|
14
|
+
await queryRunner.query(
|
|
15
|
+
`ALTER TABLE "GlobalConfig" ADD "smtpClientId" character varying(100)`,
|
|
16
|
+
);
|
|
17
|
+
await queryRunner.query(
|
|
18
|
+
`ALTER TABLE "GlobalConfig" ADD "smtpClientSecret" text`,
|
|
19
|
+
);
|
|
20
|
+
await queryRunner.query(
|
|
21
|
+
`ALTER TABLE "GlobalConfig" ADD "smtpTokenUrl" text`,
|
|
22
|
+
);
|
|
23
|
+
await queryRunner.query(
|
|
24
|
+
`ALTER TABLE "GlobalConfig" ADD "smtpScope" character varying(500)`,
|
|
25
|
+
);
|
|
26
|
+
await queryRunner.query(
|
|
27
|
+
`ALTER TABLE "GlobalConfig" ADD "smtpOAuthProviderType" character varying(100)`,
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
32
|
+
await queryRunner.query(
|
|
33
|
+
`ALTER TABLE "GlobalConfig" DROP COLUMN "smtpOAuthProviderType"`,
|
|
34
|
+
);
|
|
35
|
+
await queryRunner.query(
|
|
36
|
+
`ALTER TABLE "GlobalConfig" DROP COLUMN "smtpScope"`,
|
|
37
|
+
);
|
|
38
|
+
await queryRunner.query(
|
|
39
|
+
`ALTER TABLE "GlobalConfig" DROP COLUMN "smtpTokenUrl"`,
|
|
40
|
+
);
|
|
41
|
+
await queryRunner.query(
|
|
42
|
+
`ALTER TABLE "GlobalConfig" DROP COLUMN "smtpClientSecret"`,
|
|
43
|
+
);
|
|
44
|
+
await queryRunner.query(
|
|
45
|
+
`ALTER TABLE "GlobalConfig" DROP COLUMN "smtpClientId"`,
|
|
46
|
+
);
|
|
47
|
+
await queryRunner.query(
|
|
48
|
+
`ALTER TABLE "GlobalConfig" DROP COLUMN "smtpAuthType"`,
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -268,6 +268,7 @@ import { MigrationName1773402621107 } from "./1773402621107-MigrationName";
|
|
|
268
268
|
import { MigrationName1773676206197 } from "./1773676206197-MigrationName";
|
|
269
269
|
import { MigrationName1774000000000 } from "./1774000000000-MigrationName";
|
|
270
270
|
import { MigrationName1774000000001 } from "./1774000000001-MigrationName";
|
|
271
|
+
import { MigrationName1774000000002 } from "./1774000000002-MigrationName";
|
|
271
272
|
import { MigrationName1774355321449 } from "./1774355321449-MigrationName";
|
|
272
273
|
import { MigrationName1774357353502 } from "./1774357353502-MigrationName";
|
|
273
274
|
import { MigrationName1774524742177 } from "./1774524742177-MigrationName";
|
|
@@ -277,6 +278,8 @@ import { MigrationName1774559064919 } from "./1774559064919-MigrationName";
|
|
|
277
278
|
import { MigrationName1774559064920 } from "./1774559064920-MigrationName";
|
|
278
279
|
import { MigrationName1774559064921 } from "./1774559064921-MigrationName";
|
|
279
280
|
import { MigrationName1775735059360 } from "./1775735059360-MigrationName";
|
|
281
|
+
import { MigrationName1775766676723 } from "./1775766676723-MigrationName";
|
|
282
|
+
import { AddGlobalSmtpOAuth1775900000000 } from "./1775900000000-AddGlobalSmtpOAuth";
|
|
280
283
|
|
|
281
284
|
export default [
|
|
282
285
|
InitialMigration,
|
|
@@ -549,6 +552,7 @@ export default [
|
|
|
549
552
|
MigrationName1773676206197,
|
|
550
553
|
MigrationName1774000000000,
|
|
551
554
|
MigrationName1774000000001,
|
|
555
|
+
MigrationName1774000000002,
|
|
552
556
|
MigrationName1774355321449,
|
|
553
557
|
MigrationName1774357353502,
|
|
554
558
|
MigrationName1774524742177,
|
|
@@ -558,4 +562,6 @@ export default [
|
|
|
558
562
|
MigrationName1774559064920,
|
|
559
563
|
MigrationName1774559064921,
|
|
560
564
|
MigrationName1775735059360,
|
|
565
|
+
MigrationName1775766676723,
|
|
566
|
+
AddGlobalSmtpOAuth1775900000000,
|
|
561
567
|
];
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import DatabaseService from "./DatabaseService";
|
|
2
|
+
import Model from "../../Models/DatabaseModels/DockerHost";
|
|
3
|
+
import CaptureSpan from "../Utils/Telemetry/CaptureSpan";
|
|
4
|
+
import ObjectID from "../../Types/ObjectID";
|
|
5
|
+
import QueryHelper from "../Types/Database/QueryHelper";
|
|
6
|
+
import OneUptimeDate from "../../Types/Date";
|
|
7
|
+
import LIMIT_MAX from "../../Types/Database/LimitMax";
|
|
8
|
+
import GlobalCache from "../Infrastructure/GlobalCache";
|
|
9
|
+
|
|
10
|
+
const LAST_SEEN_CACHE_NAMESPACE: string = "docker-host-last-seen";
|
|
11
|
+
const LAST_SEEN_THROTTLE_SECONDS: number = 60;
|
|
12
|
+
|
|
13
|
+
export class Service extends DatabaseService<Model> {
|
|
14
|
+
public constructor() {
|
|
15
|
+
super(Model);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@CaptureSpan()
|
|
19
|
+
public async findOrCreateByHostIdentifier(data: {
|
|
20
|
+
projectId: ObjectID;
|
|
21
|
+
hostIdentifier: string;
|
|
22
|
+
}): Promise<Model> {
|
|
23
|
+
// Try to find existing host
|
|
24
|
+
const existingHost: Model | null = await this.findOneBy({
|
|
25
|
+
query: {
|
|
26
|
+
projectId: data.projectId,
|
|
27
|
+
hostIdentifier: data.hostIdentifier,
|
|
28
|
+
},
|
|
29
|
+
select: {
|
|
30
|
+
_id: true,
|
|
31
|
+
projectId: true,
|
|
32
|
+
hostIdentifier: true,
|
|
33
|
+
},
|
|
34
|
+
props: {
|
|
35
|
+
isRoot: true,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
if (existingHost) {
|
|
40
|
+
return existingHost;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
// Create new host
|
|
45
|
+
const newHost: Model = new Model();
|
|
46
|
+
newHost.projectId = data.projectId;
|
|
47
|
+
newHost.name = data.hostIdentifier;
|
|
48
|
+
newHost.hostIdentifier = data.hostIdentifier;
|
|
49
|
+
newHost.otelCollectorStatus = "connected";
|
|
50
|
+
newHost.lastSeenAt = OneUptimeDate.getCurrentDate();
|
|
51
|
+
|
|
52
|
+
const createdHost: Model = await this.create({
|
|
53
|
+
data: newHost,
|
|
54
|
+
props: {
|
|
55
|
+
isRoot: true,
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
return createdHost;
|
|
60
|
+
} catch {
|
|
61
|
+
/*
|
|
62
|
+
* Race condition: another request created the host concurrently.
|
|
63
|
+
* Re-fetch the existing host.
|
|
64
|
+
*/
|
|
65
|
+
const reFetchedHost: Model | null = await this.findOneBy({
|
|
66
|
+
query: {
|
|
67
|
+
projectId: data.projectId,
|
|
68
|
+
hostIdentifier: data.hostIdentifier,
|
|
69
|
+
},
|
|
70
|
+
select: {
|
|
71
|
+
_id: true,
|
|
72
|
+
projectId: true,
|
|
73
|
+
hostIdentifier: true,
|
|
74
|
+
},
|
|
75
|
+
props: {
|
|
76
|
+
isRoot: true,
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
if (reFetchedHost) {
|
|
81
|
+
return reFetchedHost;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
throw new Error(
|
|
85
|
+
"Failed to create or find Docker host: " + data.hostIdentifier,
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@CaptureSpan()
|
|
91
|
+
public async updateLastSeen(
|
|
92
|
+
hostId: ObjectID,
|
|
93
|
+
extra?: {
|
|
94
|
+
osType?: string | undefined;
|
|
95
|
+
osVersion?: string | undefined;
|
|
96
|
+
},
|
|
97
|
+
): Promise<void> {
|
|
98
|
+
const cacheKey: string = hostId.toString();
|
|
99
|
+
|
|
100
|
+
const cached: string | null = await GlobalCache.getString(
|
|
101
|
+
LAST_SEEN_CACHE_NAMESPACE,
|
|
102
|
+
cacheKey,
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
if (cached) {
|
|
106
|
+
return; // another pod already updated recently
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
await GlobalCache.setString(LAST_SEEN_CACHE_NAMESPACE, cacheKey, "1", {
|
|
110
|
+
expiresInSeconds: LAST_SEEN_THROTTLE_SECONDS,
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
114
|
+
const data: any = {
|
|
115
|
+
lastSeenAt: OneUptimeDate.getCurrentDate(),
|
|
116
|
+
otelCollectorStatus: "connected",
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
if (extra?.osType) {
|
|
120
|
+
data.osType = extra.osType;
|
|
121
|
+
}
|
|
122
|
+
if (extra?.osVersion) {
|
|
123
|
+
data.osVersion = extra.osVersion;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
await this.updateOneById({
|
|
127
|
+
id: hostId,
|
|
128
|
+
data: data,
|
|
129
|
+
props: {
|
|
130
|
+
isRoot: true,
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
@CaptureSpan()
|
|
136
|
+
public async markDisconnectedHosts(): Promise<void> {
|
|
137
|
+
const fiveMinutesAgo: Date = OneUptimeDate.addRemoveMinutes(
|
|
138
|
+
OneUptimeDate.getCurrentDate(),
|
|
139
|
+
-5,
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
const connectedHosts: Array<Model> = await this.findBy({
|
|
143
|
+
query: {
|
|
144
|
+
otelCollectorStatus: "connected",
|
|
145
|
+
lastSeenAt: QueryHelper.lessThan(fiveMinutesAgo),
|
|
146
|
+
},
|
|
147
|
+
select: {
|
|
148
|
+
_id: true,
|
|
149
|
+
},
|
|
150
|
+
limit: LIMIT_MAX,
|
|
151
|
+
skip: 0,
|
|
152
|
+
props: {
|
|
153
|
+
isRoot: true,
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
for (const host of connectedHosts) {
|
|
158
|
+
if (host._id) {
|
|
159
|
+
await this.updateOneById({
|
|
160
|
+
id: new ObjectID(host._id.toString()),
|
|
161
|
+
data: {
|
|
162
|
+
otelCollectorStatus: "disconnected",
|
|
163
|
+
},
|
|
164
|
+
props: {
|
|
165
|
+
isRoot: true,
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export default new Service();
|