@oneuptime/common 10.0.94 → 10.0.97
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/Log.ts +6 -0
- package/Models/AnalyticsModels/Metric.ts +6 -0
- package/Models/AnalyticsModels/Profile.ts +6 -0
- package/Models/AnalyticsModels/Span.ts +6 -0
- package/Models/DatabaseModels/Alert.ts +52 -0
- package/Models/DatabaseModels/DockerHost.ts +3 -10
- package/Models/DatabaseModels/Host.ts +1015 -0
- package/Models/DatabaseModels/HostOwnerTeam.ts +462 -0
- package/Models/DatabaseModels/HostOwnerUser.ts +461 -0
- package/Models/DatabaseModels/Incident.ts +52 -0
- package/Models/DatabaseModels/Index.ts +6 -0
- package/Models/DatabaseModels/KubernetesCluster.ts +0 -7
- package/Server/Infrastructure/Postgres/SchemaMigrations/1778006035712-AddHostTables.ts +201 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1778013317872-AddHostIpAddresses.ts +15 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1778066346303-WidenHostOsVersionToLongText.ts +42 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1778070278986-MigrationName.ts +79 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +8 -0
- package/Server/Services/HostOwnerTeamService.ts +10 -0
- package/Server/Services/HostOwnerUserService.ts +10 -0
- package/Server/Services/HostService.ts +227 -0
- package/Server/Services/LogAggregationService.ts +10 -3
- package/Server/Services/MetricService.ts +200 -0
- package/Server/Services/MonitorTemplateService.ts +11 -3
- package/Server/Services/TraceAggregationService.ts +8 -3
- package/Server/Utils/AnalyticsDatabase/StatementGenerator.ts +46 -18
- package/Server/Utils/Monitor/MonitorAlert.ts +31 -0
- package/Server/Utils/Monitor/MonitorIncident.ts +31 -0
- package/Server/Utils/VM/VMRunner.ts +62 -0
- package/Tests/Server/Services/LogAggregationService.test.ts +25 -0
- package/Tests/Server/Utils/AnalyticsDatabase/StatementGenerator.test.ts +145 -0
- package/Types/Metrics/MetricQueryConfigData.ts +9 -0
- package/Types/Permission.ts +134 -0
- package/UI/Components/Charts/Area/AreaChart.tsx +1 -1
- package/UI/Components/Charts/Bar/BarChart.tsx +1 -1
- package/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.tsx +15 -8
- package/UI/Components/Charts/ChartLibrary/BarChart/BarChart.tsx +12 -9
- package/UI/Components/Charts/ChartLibrary/LineChart/LineChart.tsx +17 -10
- package/UI/Components/Charts/Line/LineChart.tsx +1 -1
- package/UI/Components/ExpandableText/ExpandableText.tsx +29 -7
- package/UI/Components/JSONTable/JSONTable.tsx +27 -1
- package/UI/Components/LogsViewer/LogsViewer.tsx +3 -0
- package/UI/Components/LogsViewer/components/LogDetailsPanel.tsx +109 -23
- package/UI/Components/LogsViewer/components/LogSearchBar.tsx +11 -4
- package/UI/Components/Navbar/NavBarMenu.tsx +17 -2
- package/UI/Components/TelemetryViewer/components/TelemetrySearchBar.tsx +10 -3
- package/Utils/ValueFormatter.ts +57 -3
- package/build/dist/Models/AnalyticsModels/Log.js +6 -0
- package/build/dist/Models/AnalyticsModels/Log.js.map +1 -1
- package/build/dist/Models/AnalyticsModels/Metric.js +6 -0
- package/build/dist/Models/AnalyticsModels/Metric.js.map +1 -1
- package/build/dist/Models/AnalyticsModels/Profile.js +6 -0
- package/build/dist/Models/AnalyticsModels/Profile.js.map +1 -1
- package/build/dist/Models/AnalyticsModels/Span.js +6 -0
- package/build/dist/Models/AnalyticsModels/Span.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Alert.js +51 -0
- package/build/dist/Models/DatabaseModels/Alert.js.map +1 -1
- package/build/dist/Models/DatabaseModels/DockerHost.js +3 -10
- package/build/dist/Models/DatabaseModels/DockerHost.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Host.js +1041 -0
- package/build/dist/Models/DatabaseModels/Host.js.map +1 -0
- package/build/dist/Models/DatabaseModels/HostOwnerTeam.js +480 -0
- package/build/dist/Models/DatabaseModels/HostOwnerTeam.js.map +1 -0
- package/build/dist/Models/DatabaseModels/HostOwnerUser.js +479 -0
- package/build/dist/Models/DatabaseModels/HostOwnerUser.js.map +1 -0
- package/build/dist/Models/DatabaseModels/Incident.js +51 -0
- package/build/dist/Models/DatabaseModels/Incident.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Index.js +6 -0
- package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
- package/build/dist/Models/DatabaseModels/KubernetesCluster.js +0 -7
- package/build/dist/Models/DatabaseModels/KubernetesCluster.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1778006035712-AddHostTables.js +76 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1778006035712-AddHostTables.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1778013317872-AddHostIpAddresses.js +12 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1778013317872-AddHostIpAddresses.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1778066346303-WidenHostOsVersionToLongText.js +31 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1778066346303-WidenHostOsVersionToLongText.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1778070278986-MigrationName.js +34 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1778070278986-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/HostOwnerTeamService.js +9 -0
- package/build/dist/Server/Services/HostOwnerTeamService.js.map +1 -0
- package/build/dist/Server/Services/HostOwnerUserService.js +9 -0
- package/build/dist/Server/Services/HostOwnerUserService.js.map +1 -0
- package/build/dist/Server/Services/HostService.js +206 -0
- package/build/dist/Server/Services/HostService.js.map +1 -0
- package/build/dist/Server/Services/LogAggregationService.js +10 -3
- package/build/dist/Server/Services/LogAggregationService.js.map +1 -1
- package/build/dist/Server/Services/MetricService.js +160 -0
- package/build/dist/Server/Services/MetricService.js.map +1 -1
- package/build/dist/Server/Services/MonitorTemplateService.js +7 -0
- package/build/dist/Server/Services/MonitorTemplateService.js.map +1 -1
- package/build/dist/Server/Services/TraceAggregationService.js +8 -3
- package/build/dist/Server/Services/TraceAggregationService.js.map +1 -1
- package/build/dist/Server/Utils/AnalyticsDatabase/StatementGenerator.js +46 -18
- package/build/dist/Server/Utils/AnalyticsDatabase/StatementGenerator.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorAlert.js +26 -0
- package/build/dist/Server/Utils/Monitor/MonitorAlert.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorIncident.js +26 -0
- package/build/dist/Server/Utils/Monitor/MonitorIncident.js.map +1 -1
- package/build/dist/Server/Utils/VM/VMRunner.js +61 -0
- package/build/dist/Server/Utils/VM/VMRunner.js.map +1 -1
- package/build/dist/Tests/Server/Services/LogAggregationService.test.js +13 -0
- package/build/dist/Tests/Server/Services/LogAggregationService.test.js.map +1 -1
- package/build/dist/Tests/Server/Utils/AnalyticsDatabase/StatementGenerator.test.js +123 -0
- package/build/dist/Tests/Server/Utils/AnalyticsDatabase/StatementGenerator.test.js.map +1 -1
- package/build/dist/Types/Permission.js +120 -0
- package/build/dist/Types/Permission.js.map +1 -1
- package/build/dist/UI/Components/Charts/Area/AreaChart.js +1 -1
- package/build/dist/UI/Components/Charts/Bar/BarChart.js +1 -1
- package/build/dist/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.js +13 -7
- package/build/dist/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.js.map +1 -1
- package/build/dist/UI/Components/Charts/ChartLibrary/BarChart/BarChart.js +11 -9
- package/build/dist/UI/Components/Charts/ChartLibrary/BarChart/BarChart.js.map +1 -1
- package/build/dist/UI/Components/Charts/ChartLibrary/LineChart/LineChart.js +16 -10
- package/build/dist/UI/Components/Charts/ChartLibrary/LineChart/LineChart.js.map +1 -1
- package/build/dist/UI/Components/Charts/Line/LineChart.js +1 -1
- package/build/dist/UI/Components/ExpandableText/ExpandableText.js +10 -5
- package/build/dist/UI/Components/ExpandableText/ExpandableText.js.map +1 -1
- package/build/dist/UI/Components/JSONTable/JSONTable.js +8 -1
- package/build/dist/UI/Components/JSONTable/JSONTable.js.map +1 -1
- package/build/dist/UI/Components/LogsViewer/LogsViewer.js +1 -1
- package/build/dist/UI/Components/LogsViewer/LogsViewer.js.map +1 -1
- package/build/dist/UI/Components/LogsViewer/components/LogDetailsPanel.js +40 -14
- package/build/dist/UI/Components/LogsViewer/components/LogDetailsPanel.js.map +1 -1
- package/build/dist/UI/Components/LogsViewer/components/LogSearchBar.js +10 -4
- package/build/dist/UI/Components/LogsViewer/components/LogSearchBar.js.map +1 -1
- package/build/dist/UI/Components/Navbar/NavBarMenu.js +15 -2
- package/build/dist/UI/Components/Navbar/NavBarMenu.js.map +1 -1
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetrySearchBar.js +10 -3
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetrySearchBar.js.map +1 -1
- package/build/dist/Utils/ValueFormatter.js +47 -3
- package/build/dist/Utils/ValueFormatter.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
2
|
+
|
|
3
|
+
export class AddHostTables1778006035712 implements MigrationInterface {
|
|
4
|
+
public name = "AddHostTables1778006035712";
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(
|
|
8
|
+
`CREATE TABLE "Host" ("_id" uuid NOT NULL DEFAULT uuid_generate_v4(), "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "deletedAt" TIMESTAMP WITH TIME ZONE, "version" integer NOT NULL, "projectId" uuid NOT NULL, "name" character varying(100) NOT NULL, "slug" character varying(100) NOT NULL, "description" character varying(500), "hostIdentifier" character varying(100) NOT NULL, "otelCollectorStatus" character varying(100) DEFAULT 'disconnected', "lastSeenAt" TIMESTAMP WITH TIME ZONE, "osType" character varying(100), "osVersion" character varying(100), "hostId" character varying(100), "hostArch" character varying(100), "hostType" character varying(100), "cpuCores" integer, "totalMemoryBytes" bigint, "processCount" integer, "containerRuntime" character varying(100), "dockerHostId" uuid, "kubernetesClusterId" uuid, "createdByUserId" uuid, "deletedByUserId" uuid, CONSTRAINT "PK_8932b1fbd5379a13b1b36ec2d3d" PRIMARY KEY ("_id"))`,
|
|
9
|
+
);
|
|
10
|
+
await queryRunner.query(
|
|
11
|
+
`CREATE INDEX "IDX_e22ae9b0a967fb6543ff8c301f" ON "Host" ("projectId") `,
|
|
12
|
+
);
|
|
13
|
+
await queryRunner.query(
|
|
14
|
+
`CREATE INDEX "IDX_3fde0ad120dcc2add43571d32f" ON "Host" ("hostIdentifier") `,
|
|
15
|
+
);
|
|
16
|
+
await queryRunner.query(
|
|
17
|
+
`CREATE TABLE "HostOwnerTeam" ("_id" uuid NOT NULL DEFAULT uuid_generate_v4(), "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "deletedAt" TIMESTAMP WITH TIME ZONE, "version" integer NOT NULL, "projectId" uuid NOT NULL, "teamId" uuid NOT NULL, "hostId" uuid NOT NULL, "createdByUserId" uuid, "deletedByUserId" uuid, "isOwnerNotified" boolean NOT NULL DEFAULT false, CONSTRAINT "PK_84405badc1534865339c8c5e406" PRIMARY KEY ("_id"))`,
|
|
18
|
+
);
|
|
19
|
+
await queryRunner.query(
|
|
20
|
+
`CREATE INDEX "IDX_c1d978cf937110822c0a8c16b6" ON "HostOwnerTeam" ("projectId") `,
|
|
21
|
+
);
|
|
22
|
+
await queryRunner.query(
|
|
23
|
+
`CREATE INDEX "IDX_1290ff7710538a05b836d6963f" ON "HostOwnerTeam" ("teamId") `,
|
|
24
|
+
);
|
|
25
|
+
await queryRunner.query(
|
|
26
|
+
`CREATE INDEX "IDX_cfd5c58b1da0f125d89e18e0bc" ON "HostOwnerTeam" ("hostId") `,
|
|
27
|
+
);
|
|
28
|
+
await queryRunner.query(
|
|
29
|
+
`CREATE INDEX "IDX_495bfc6fd17ac913d87b4e1343" ON "HostOwnerTeam" ("isOwnerNotified") `,
|
|
30
|
+
);
|
|
31
|
+
await queryRunner.query(
|
|
32
|
+
`CREATE TABLE "HostOwnerUser" ("_id" uuid NOT NULL DEFAULT uuid_generate_v4(), "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "deletedAt" TIMESTAMP WITH TIME ZONE, "version" integer NOT NULL, "projectId" uuid NOT NULL, "userId" uuid NOT NULL, "hostId" uuid NOT NULL, "createdByUserId" uuid, "deletedByUserId" uuid, "isOwnerNotified" boolean NOT NULL DEFAULT false, CONSTRAINT "PK_0162afb1404ef9533b18c896e4e" PRIMARY KEY ("_id"))`,
|
|
33
|
+
);
|
|
34
|
+
await queryRunner.query(
|
|
35
|
+
`CREATE INDEX "IDX_0a702bcd1aae2116c995c9e629" ON "HostOwnerUser" ("projectId") `,
|
|
36
|
+
);
|
|
37
|
+
await queryRunner.query(
|
|
38
|
+
`CREATE INDEX "IDX_3defdc18ccc7f39331f2421642" ON "HostOwnerUser" ("userId") `,
|
|
39
|
+
);
|
|
40
|
+
await queryRunner.query(
|
|
41
|
+
`CREATE INDEX "IDX_548d344a8aacbfcfe9c7e976d2" ON "HostOwnerUser" ("hostId") `,
|
|
42
|
+
);
|
|
43
|
+
await queryRunner.query(
|
|
44
|
+
`CREATE INDEX "IDX_b31e255a3a84c744f345655de3" ON "HostOwnerUser" ("isOwnerNotified") `,
|
|
45
|
+
);
|
|
46
|
+
await queryRunner.query(
|
|
47
|
+
`CREATE TABLE "HostLabel" ("hostId" uuid NOT NULL, "labelId" uuid NOT NULL, CONSTRAINT "PK_86a7f1b9bc210b18c81113b5a33" PRIMARY KEY ("hostId", "labelId"))`,
|
|
48
|
+
);
|
|
49
|
+
await queryRunner.query(
|
|
50
|
+
`CREATE INDEX "IDX_59e952ca592c04398e3d64bfde" ON "HostLabel" ("hostId") `,
|
|
51
|
+
);
|
|
52
|
+
await queryRunner.query(
|
|
53
|
+
`CREATE INDEX "IDX_9430f41b66935ad844c956aee6" ON "HostLabel" ("labelId") `,
|
|
54
|
+
);
|
|
55
|
+
await queryRunner.query(
|
|
56
|
+
`ALTER TABLE "Host" ADD CONSTRAINT "FK_e22ae9b0a967fb6543ff8c301f1" FOREIGN KEY ("projectId") REFERENCES "Project"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
57
|
+
);
|
|
58
|
+
await queryRunner.query(
|
|
59
|
+
`ALTER TABLE "Host" ADD CONSTRAINT "FK_4bd303f959a5149deaf49cc7829" FOREIGN KEY ("dockerHostId") REFERENCES "DockerHost"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
|
|
60
|
+
);
|
|
61
|
+
await queryRunner.query(
|
|
62
|
+
`ALTER TABLE "Host" ADD CONSTRAINT "FK_f3aaabe9c2b44fb291de44db2b8" FOREIGN KEY ("kubernetesClusterId") REFERENCES "KubernetesCluster"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
|
|
63
|
+
);
|
|
64
|
+
await queryRunner.query(
|
|
65
|
+
`ALTER TABLE "Host" ADD CONSTRAINT "FK_d49356815c565cb9d8daddbb673" FOREIGN KEY ("createdByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
|
|
66
|
+
);
|
|
67
|
+
await queryRunner.query(
|
|
68
|
+
`ALTER TABLE "Host" ADD CONSTRAINT "FK_aa5c88e1babc531c2f494117f2e" FOREIGN KEY ("deletedByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
|
|
69
|
+
);
|
|
70
|
+
await queryRunner.query(
|
|
71
|
+
`ALTER TABLE "HostOwnerTeam" ADD CONSTRAINT "FK_c1d978cf937110822c0a8c16b63" FOREIGN KEY ("projectId") REFERENCES "Project"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
72
|
+
);
|
|
73
|
+
await queryRunner.query(
|
|
74
|
+
`ALTER TABLE "HostOwnerTeam" ADD CONSTRAINT "FK_1290ff7710538a05b836d6963f5" FOREIGN KEY ("teamId") REFERENCES "Team"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
75
|
+
);
|
|
76
|
+
await queryRunner.query(
|
|
77
|
+
`ALTER TABLE "HostOwnerTeam" ADD CONSTRAINT "FK_cfd5c58b1da0f125d89e18e0bc8" FOREIGN KEY ("hostId") REFERENCES "Host"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
78
|
+
);
|
|
79
|
+
await queryRunner.query(
|
|
80
|
+
`ALTER TABLE "HostOwnerTeam" ADD CONSTRAINT "FK_ee4a1b1c2c24c1b2e9a75aa16c9" FOREIGN KEY ("createdByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
|
|
81
|
+
);
|
|
82
|
+
await queryRunner.query(
|
|
83
|
+
`ALTER TABLE "HostOwnerTeam" ADD CONSTRAINT "FK_6d4be0abe0aafe5f92dabe17c39" FOREIGN KEY ("deletedByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
|
|
84
|
+
);
|
|
85
|
+
await queryRunner.query(
|
|
86
|
+
`ALTER TABLE "HostOwnerUser" ADD CONSTRAINT "FK_0a702bcd1aae2116c995c9e6294" FOREIGN KEY ("projectId") REFERENCES "Project"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
87
|
+
);
|
|
88
|
+
await queryRunner.query(
|
|
89
|
+
`ALTER TABLE "HostOwnerUser" ADD CONSTRAINT "FK_3defdc18ccc7f39331f24216427" FOREIGN KEY ("userId") REFERENCES "User"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
90
|
+
);
|
|
91
|
+
await queryRunner.query(
|
|
92
|
+
`ALTER TABLE "HostOwnerUser" ADD CONSTRAINT "FK_548d344a8aacbfcfe9c7e976d22" FOREIGN KEY ("hostId") REFERENCES "Host"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
93
|
+
);
|
|
94
|
+
await queryRunner.query(
|
|
95
|
+
`ALTER TABLE "HostOwnerUser" ADD CONSTRAINT "FK_77c8d3ccc2887cd21f6fee2e283" FOREIGN KEY ("createdByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
|
|
96
|
+
);
|
|
97
|
+
await queryRunner.query(
|
|
98
|
+
`ALTER TABLE "HostOwnerUser" ADD CONSTRAINT "FK_aae3727b2c7f6567667f367996a" FOREIGN KEY ("deletedByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
|
|
99
|
+
);
|
|
100
|
+
await queryRunner.query(
|
|
101
|
+
`ALTER TABLE "HostLabel" ADD CONSTRAINT "FK_59e952ca592c04398e3d64bfde6" FOREIGN KEY ("hostId") REFERENCES "Host"("_id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
|
102
|
+
);
|
|
103
|
+
await queryRunner.query(
|
|
104
|
+
`ALTER TABLE "HostLabel" ADD CONSTRAINT "FK_9430f41b66935ad844c956aee6a" FOREIGN KEY ("labelId") REFERENCES "Label"("_id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
109
|
+
await queryRunner.query(
|
|
110
|
+
`ALTER TABLE "HostLabel" DROP CONSTRAINT "FK_9430f41b66935ad844c956aee6a"`,
|
|
111
|
+
);
|
|
112
|
+
await queryRunner.query(
|
|
113
|
+
`ALTER TABLE "HostLabel" DROP CONSTRAINT "FK_59e952ca592c04398e3d64bfde6"`,
|
|
114
|
+
);
|
|
115
|
+
await queryRunner.query(
|
|
116
|
+
`ALTER TABLE "HostOwnerUser" DROP CONSTRAINT "FK_aae3727b2c7f6567667f367996a"`,
|
|
117
|
+
);
|
|
118
|
+
await queryRunner.query(
|
|
119
|
+
`ALTER TABLE "HostOwnerUser" DROP CONSTRAINT "FK_77c8d3ccc2887cd21f6fee2e283"`,
|
|
120
|
+
);
|
|
121
|
+
await queryRunner.query(
|
|
122
|
+
`ALTER TABLE "HostOwnerUser" DROP CONSTRAINT "FK_548d344a8aacbfcfe9c7e976d22"`,
|
|
123
|
+
);
|
|
124
|
+
await queryRunner.query(
|
|
125
|
+
`ALTER TABLE "HostOwnerUser" DROP CONSTRAINT "FK_3defdc18ccc7f39331f24216427"`,
|
|
126
|
+
);
|
|
127
|
+
await queryRunner.query(
|
|
128
|
+
`ALTER TABLE "HostOwnerUser" DROP CONSTRAINT "FK_0a702bcd1aae2116c995c9e6294"`,
|
|
129
|
+
);
|
|
130
|
+
await queryRunner.query(
|
|
131
|
+
`ALTER TABLE "HostOwnerTeam" DROP CONSTRAINT "FK_6d4be0abe0aafe5f92dabe17c39"`,
|
|
132
|
+
);
|
|
133
|
+
await queryRunner.query(
|
|
134
|
+
`ALTER TABLE "HostOwnerTeam" DROP CONSTRAINT "FK_ee4a1b1c2c24c1b2e9a75aa16c9"`,
|
|
135
|
+
);
|
|
136
|
+
await queryRunner.query(
|
|
137
|
+
`ALTER TABLE "HostOwnerTeam" DROP CONSTRAINT "FK_cfd5c58b1da0f125d89e18e0bc8"`,
|
|
138
|
+
);
|
|
139
|
+
await queryRunner.query(
|
|
140
|
+
`ALTER TABLE "HostOwnerTeam" DROP CONSTRAINT "FK_1290ff7710538a05b836d6963f5"`,
|
|
141
|
+
);
|
|
142
|
+
await queryRunner.query(
|
|
143
|
+
`ALTER TABLE "HostOwnerTeam" DROP CONSTRAINT "FK_c1d978cf937110822c0a8c16b63"`,
|
|
144
|
+
);
|
|
145
|
+
await queryRunner.query(
|
|
146
|
+
`ALTER TABLE "Host" DROP CONSTRAINT "FK_aa5c88e1babc531c2f494117f2e"`,
|
|
147
|
+
);
|
|
148
|
+
await queryRunner.query(
|
|
149
|
+
`ALTER TABLE "Host" DROP CONSTRAINT "FK_d49356815c565cb9d8daddbb673"`,
|
|
150
|
+
);
|
|
151
|
+
await queryRunner.query(
|
|
152
|
+
`ALTER TABLE "Host" DROP CONSTRAINT "FK_f3aaabe9c2b44fb291de44db2b8"`,
|
|
153
|
+
);
|
|
154
|
+
await queryRunner.query(
|
|
155
|
+
`ALTER TABLE "Host" DROP CONSTRAINT "FK_4bd303f959a5149deaf49cc7829"`,
|
|
156
|
+
);
|
|
157
|
+
await queryRunner.query(
|
|
158
|
+
`ALTER TABLE "Host" DROP CONSTRAINT "FK_e22ae9b0a967fb6543ff8c301f1"`,
|
|
159
|
+
);
|
|
160
|
+
await queryRunner.query(
|
|
161
|
+
`DROP INDEX "public"."IDX_9430f41b66935ad844c956aee6"`,
|
|
162
|
+
);
|
|
163
|
+
await queryRunner.query(
|
|
164
|
+
`DROP INDEX "public"."IDX_59e952ca592c04398e3d64bfde"`,
|
|
165
|
+
);
|
|
166
|
+
await queryRunner.query(`DROP TABLE "HostLabel"`);
|
|
167
|
+
await queryRunner.query(
|
|
168
|
+
`DROP INDEX "public"."IDX_b31e255a3a84c744f345655de3"`,
|
|
169
|
+
);
|
|
170
|
+
await queryRunner.query(
|
|
171
|
+
`DROP INDEX "public"."IDX_548d344a8aacbfcfe9c7e976d2"`,
|
|
172
|
+
);
|
|
173
|
+
await queryRunner.query(
|
|
174
|
+
`DROP INDEX "public"."IDX_3defdc18ccc7f39331f2421642"`,
|
|
175
|
+
);
|
|
176
|
+
await queryRunner.query(
|
|
177
|
+
`DROP INDEX "public"."IDX_0a702bcd1aae2116c995c9e629"`,
|
|
178
|
+
);
|
|
179
|
+
await queryRunner.query(`DROP TABLE "HostOwnerUser"`);
|
|
180
|
+
await queryRunner.query(
|
|
181
|
+
`DROP INDEX "public"."IDX_495bfc6fd17ac913d87b4e1343"`,
|
|
182
|
+
);
|
|
183
|
+
await queryRunner.query(
|
|
184
|
+
`DROP INDEX "public"."IDX_cfd5c58b1da0f125d89e18e0bc"`,
|
|
185
|
+
);
|
|
186
|
+
await queryRunner.query(
|
|
187
|
+
`DROP INDEX "public"."IDX_1290ff7710538a05b836d6963f"`,
|
|
188
|
+
);
|
|
189
|
+
await queryRunner.query(
|
|
190
|
+
`DROP INDEX "public"."IDX_c1d978cf937110822c0a8c16b6"`,
|
|
191
|
+
);
|
|
192
|
+
await queryRunner.query(`DROP TABLE "HostOwnerTeam"`);
|
|
193
|
+
await queryRunner.query(
|
|
194
|
+
`DROP INDEX "public"."IDX_3fde0ad120dcc2add43571d32f"`,
|
|
195
|
+
);
|
|
196
|
+
await queryRunner.query(
|
|
197
|
+
`DROP INDEX "public"."IDX_e22ae9b0a967fb6543ff8c301f"`,
|
|
198
|
+
);
|
|
199
|
+
await queryRunner.query(`DROP TABLE "Host"`);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
2
|
+
|
|
3
|
+
export class AddHostIpAddresses1778013317872 implements MigrationInterface {
|
|
4
|
+
public name = "AddHostIpAddresses1778013317872";
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(
|
|
8
|
+
`ALTER TABLE "Host" ADD "hostIpAddresses" character varying(500)`,
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
13
|
+
await queryRunner.query(`ALTER TABLE "Host" DROP COLUMN "hostIpAddresses"`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* macOS resourcedetection reports os.description as the full uname output
|
|
5
|
+
* (e.g. "macOS 26.3.1 (25D2128) (Darwin … Kernel Version … RELEASE_ARM64_T6000 arm64)"),
|
|
6
|
+
* which exceeds the 100-char ShortText limit. The OTel ingest pipeline
|
|
7
|
+
* passes osVersion through the same atomic UPDATE that sets lastSeenAt and
|
|
8
|
+
* the rest of the host metadata, so a too-long value silently failed every
|
|
9
|
+
* field on the row — including lastSeenAt — leaving newly-discovered hosts
|
|
10
|
+
* permanently empty and demoted to "disconnected" by the 5-min cron.
|
|
11
|
+
*
|
|
12
|
+
* Widen Host.osVersion and DockerHost.osVersion to LongText (500). Use
|
|
13
|
+
* ALTER COLUMN ... TYPE so existing rows keep their osVersion data instead
|
|
14
|
+
* of being wiped by the DROP+ADD pattern TypeORM auto-generated.
|
|
15
|
+
*/
|
|
16
|
+
export class WidenHostOsVersionToLongText1778066346303
|
|
17
|
+
implements MigrationInterface
|
|
18
|
+
{
|
|
19
|
+
public name: string = "WidenHostOsVersionToLongText1778066346303";
|
|
20
|
+
|
|
21
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
22
|
+
await queryRunner.query(
|
|
23
|
+
`ALTER TABLE "Host" ALTER COLUMN "osVersion" TYPE character varying(500)`,
|
|
24
|
+
);
|
|
25
|
+
await queryRunner.query(
|
|
26
|
+
`ALTER TABLE "DockerHost" ALTER COLUMN "osVersion" TYPE character varying(500)`,
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
31
|
+
/*
|
|
32
|
+
* Note: any rows with osVersion > 100 chars must be manually
|
|
33
|
+
* shortened before this rollback, otherwise the ALTER COLUMN will fail.
|
|
34
|
+
*/
|
|
35
|
+
await queryRunner.query(
|
|
36
|
+
`ALTER TABLE "DockerHost" ALTER COLUMN "osVersion" TYPE character varying(100)`,
|
|
37
|
+
);
|
|
38
|
+
await queryRunner.query(
|
|
39
|
+
`ALTER TABLE "Host" ALTER COLUMN "osVersion" TYPE character varying(100)`,
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
2
|
+
|
|
3
|
+
export class MigrationName1778070278986 implements MigrationInterface {
|
|
4
|
+
public name = "MigrationName1778070278986";
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(
|
|
8
|
+
`CREATE TABLE "IncidentHost" ("incidentId" uuid NOT NULL, "hostId" uuid NOT NULL, CONSTRAINT "PK_af405a55232f0a9b86f8e61afc8" PRIMARY KEY ("incidentId", "hostId"))`,
|
|
9
|
+
);
|
|
10
|
+
await queryRunner.query(
|
|
11
|
+
`CREATE INDEX "IDX_754c607846b4d3fed7812910af" ON "IncidentHost" ("incidentId") `,
|
|
12
|
+
);
|
|
13
|
+
await queryRunner.query(
|
|
14
|
+
`CREATE INDEX "IDX_761485a265848de15cbe146577" ON "IncidentHost" ("hostId") `,
|
|
15
|
+
);
|
|
16
|
+
await queryRunner.query(
|
|
17
|
+
`CREATE TABLE "AlertHost" ("alertId" uuid NOT NULL, "hostId" uuid NOT NULL, CONSTRAINT "PK_7d743416076d53cd4d3eb81e510" PRIMARY KEY ("alertId", "hostId"))`,
|
|
18
|
+
);
|
|
19
|
+
await queryRunner.query(
|
|
20
|
+
`CREATE INDEX "IDX_70537c0436813fa8056e5390e9" ON "AlertHost" ("alertId") `,
|
|
21
|
+
);
|
|
22
|
+
await queryRunner.query(
|
|
23
|
+
`CREATE INDEX "IDX_f241ff3816d26dfaa3ca615b18" ON "AlertHost" ("hostId") `,
|
|
24
|
+
);
|
|
25
|
+
await queryRunner.query(
|
|
26
|
+
`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type":"Recurring","value":{"intervalType":"Day","intervalCount":{"_type":"PositiveNumber","value":1}}}'`,
|
|
27
|
+
);
|
|
28
|
+
await queryRunner.query(
|
|
29
|
+
`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type":"RestrictionTimes","value":{"restictionType":"None","dayRestrictionTimes":null,"weeklyRestrictionTimes":[]}}'`,
|
|
30
|
+
);
|
|
31
|
+
await queryRunner.query(
|
|
32
|
+
`ALTER TABLE "IncidentHost" ADD CONSTRAINT "FK_754c607846b4d3fed7812910aff" FOREIGN KEY ("incidentId") REFERENCES "Incident"("_id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
|
33
|
+
);
|
|
34
|
+
await queryRunner.query(
|
|
35
|
+
`ALTER TABLE "IncidentHost" ADD CONSTRAINT "FK_761485a265848de15cbe1465776" FOREIGN KEY ("hostId") REFERENCES "Host"("_id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
|
36
|
+
);
|
|
37
|
+
await queryRunner.query(
|
|
38
|
+
`ALTER TABLE "AlertHost" ADD CONSTRAINT "FK_70537c0436813fa8056e5390e96" FOREIGN KEY ("alertId") REFERENCES "Alert"("_id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
|
39
|
+
);
|
|
40
|
+
await queryRunner.query(
|
|
41
|
+
`ALTER TABLE "AlertHost" ADD CONSTRAINT "FK_f241ff3816d26dfaa3ca615b185" FOREIGN KEY ("hostId") REFERENCES "Host"("_id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
46
|
+
await queryRunner.query(
|
|
47
|
+
`ALTER TABLE "AlertHost" DROP CONSTRAINT "FK_f241ff3816d26dfaa3ca615b185"`,
|
|
48
|
+
);
|
|
49
|
+
await queryRunner.query(
|
|
50
|
+
`ALTER TABLE "AlertHost" DROP CONSTRAINT "FK_70537c0436813fa8056e5390e96"`,
|
|
51
|
+
);
|
|
52
|
+
await queryRunner.query(
|
|
53
|
+
`ALTER TABLE "IncidentHost" DROP CONSTRAINT "FK_761485a265848de15cbe1465776"`,
|
|
54
|
+
);
|
|
55
|
+
await queryRunner.query(
|
|
56
|
+
`ALTER TABLE "IncidentHost" DROP CONSTRAINT "FK_754c607846b4d3fed7812910aff"`,
|
|
57
|
+
);
|
|
58
|
+
await queryRunner.query(
|
|
59
|
+
`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type": "RestrictionTimes", "value": {"restictionType": "None", "dayRestrictionTimes": null, "weeklyRestrictionTimes": []}}'`,
|
|
60
|
+
);
|
|
61
|
+
await queryRunner.query(
|
|
62
|
+
`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type": "Recurring", "value": {"intervalType": "Day", "intervalCount": {"_type": "PositiveNumber", "value": 1}}}'`,
|
|
63
|
+
);
|
|
64
|
+
await queryRunner.query(
|
|
65
|
+
`DROP INDEX "public"."IDX_f241ff3816d26dfaa3ca615b18"`,
|
|
66
|
+
);
|
|
67
|
+
await queryRunner.query(
|
|
68
|
+
`DROP INDEX "public"."IDX_70537c0436813fa8056e5390e9"`,
|
|
69
|
+
);
|
|
70
|
+
await queryRunner.query(`DROP TABLE "AlertHost"`);
|
|
71
|
+
await queryRunner.query(
|
|
72
|
+
`DROP INDEX "public"."IDX_761485a265848de15cbe146577"`,
|
|
73
|
+
);
|
|
74
|
+
await queryRunner.query(
|
|
75
|
+
`DROP INDEX "public"."IDX_754c607846b4d3fed7812910af"`,
|
|
76
|
+
);
|
|
77
|
+
await queryRunner.query(`DROP TABLE "IncidentHost"`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -298,6 +298,10 @@ import { MigrationName1777571961028 } from "./1777571961028-MigrationName";
|
|
|
298
298
|
import { MigrationName1777629313843 } from "./1777629313843-MigrationName";
|
|
299
299
|
import { MigrationName1777933061000 } from "./1777933061000-MigrationName";
|
|
300
300
|
import { MigrationName1777972687018 } from "./1777972687018-MigrationName";
|
|
301
|
+
import { AddHostTables1778006035712 } from "./1778006035712-AddHostTables";
|
|
302
|
+
import { AddHostIpAddresses1778013317872 } from "./1778013317872-AddHostIpAddresses";
|
|
303
|
+
import { WidenHostOsVersionToLongText1778066346303 } from "./1778066346303-WidenHostOsVersionToLongText";
|
|
304
|
+
import { MigrationName1778070278986 } from "./1778070278986-MigrationName";
|
|
301
305
|
export default [
|
|
302
306
|
InitialMigration,
|
|
303
307
|
MigrationName1717678334852,
|
|
@@ -599,4 +603,8 @@ export default [
|
|
|
599
603
|
MigrationName1777629313843,
|
|
600
604
|
MigrationName1777933061000,
|
|
601
605
|
MigrationName1777972687018,
|
|
606
|
+
AddHostTables1778006035712,
|
|
607
|
+
AddHostIpAddresses1778013317872,
|
|
608
|
+
WidenHostOsVersionToLongText1778066346303,
|
|
609
|
+
MigrationName1778070278986,
|
|
602
610
|
];
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import DatabaseService from "./DatabaseService";
|
|
2
|
+
import Model from "../../Models/DatabaseModels/Host";
|
|
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 = "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
|
+
const existingHost: Model | null = await this.findOneBy({
|
|
24
|
+
query: {
|
|
25
|
+
projectId: data.projectId,
|
|
26
|
+
hostIdentifier: data.hostIdentifier,
|
|
27
|
+
},
|
|
28
|
+
select: {
|
|
29
|
+
_id: true,
|
|
30
|
+
projectId: true,
|
|
31
|
+
hostIdentifier: true,
|
|
32
|
+
},
|
|
33
|
+
props: {
|
|
34
|
+
isRoot: true,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
if (existingHost) {
|
|
39
|
+
return existingHost;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
try {
|
|
43
|
+
const newHost: Model = new Model();
|
|
44
|
+
newHost.projectId = data.projectId;
|
|
45
|
+
newHost.name = data.hostIdentifier;
|
|
46
|
+
newHost.hostIdentifier = data.hostIdentifier;
|
|
47
|
+
newHost.otelCollectorStatus = "connected";
|
|
48
|
+
newHost.lastSeenAt = OneUptimeDate.getCurrentDate();
|
|
49
|
+
|
|
50
|
+
const createdHost: Model = await this.create({
|
|
51
|
+
data: newHost,
|
|
52
|
+
props: {
|
|
53
|
+
isRoot: true,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
return createdHost;
|
|
58
|
+
} catch {
|
|
59
|
+
const reFetchedHost: Model | null = await this.findOneBy({
|
|
60
|
+
query: {
|
|
61
|
+
projectId: data.projectId,
|
|
62
|
+
hostIdentifier: data.hostIdentifier,
|
|
63
|
+
},
|
|
64
|
+
select: {
|
|
65
|
+
_id: true,
|
|
66
|
+
projectId: true,
|
|
67
|
+
hostIdentifier: true,
|
|
68
|
+
},
|
|
69
|
+
props: {
|
|
70
|
+
isRoot: true,
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
if (reFetchedHost) {
|
|
75
|
+
return reFetchedHost;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
throw new Error("Failed to create or find host: " + data.hostIdentifier);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@CaptureSpan()
|
|
83
|
+
public async updateLastSeen(
|
|
84
|
+
hostId: ObjectID,
|
|
85
|
+
extra?: {
|
|
86
|
+
osType?: string | undefined;
|
|
87
|
+
osVersion?: string | undefined;
|
|
88
|
+
hostId?: string | undefined;
|
|
89
|
+
hostArch?: string | undefined;
|
|
90
|
+
hostType?: string | undefined;
|
|
91
|
+
hostIpAddresses?: string | undefined;
|
|
92
|
+
cpuCores?: number | undefined;
|
|
93
|
+
totalMemoryBytes?: number | undefined;
|
|
94
|
+
processCount?: number | undefined;
|
|
95
|
+
containerRuntime?: string | undefined;
|
|
96
|
+
dockerHostId?: ObjectID | undefined;
|
|
97
|
+
kubernetesClusterId?: ObjectID | undefined;
|
|
98
|
+
},
|
|
99
|
+
): Promise<void> {
|
|
100
|
+
/*
|
|
101
|
+
* Throttle the lightweight "lastSeenAt + status" pings — those
|
|
102
|
+
* arrive at every metric / log / trace batch and don't carry new
|
|
103
|
+
* information. Pings that bring richer state (host metadata,
|
|
104
|
+
* cached infra stats, runtime detection, FK links) bypass the
|
|
105
|
+
* cache so the values land promptly.
|
|
106
|
+
*/
|
|
107
|
+
const hasRichExtras: boolean = Boolean(
|
|
108
|
+
extra &&
|
|
109
|
+
(extra.hostId ||
|
|
110
|
+
extra.hostArch ||
|
|
111
|
+
extra.hostType ||
|
|
112
|
+
extra.hostIpAddresses ||
|
|
113
|
+
extra.cpuCores !== undefined ||
|
|
114
|
+
extra.totalMemoryBytes !== undefined ||
|
|
115
|
+
extra.processCount !== undefined ||
|
|
116
|
+
extra.containerRuntime ||
|
|
117
|
+
extra.dockerHostId ||
|
|
118
|
+
extra.kubernetesClusterId),
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
if (!hasRichExtras) {
|
|
122
|
+
const cacheKey: string = hostId.toString();
|
|
123
|
+
const cached: string | null = await GlobalCache.getString(
|
|
124
|
+
LAST_SEEN_CACHE_NAMESPACE,
|
|
125
|
+
cacheKey,
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
if (cached) {
|
|
129
|
+
return; // another pod already updated recently
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
await GlobalCache.setString(LAST_SEEN_CACHE_NAMESPACE, cacheKey, "1", {
|
|
133
|
+
expiresInSeconds: LAST_SEEN_THROTTLE_SECONDS,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
138
|
+
const data: any = {
|
|
139
|
+
lastSeenAt: OneUptimeDate.getCurrentDate(),
|
|
140
|
+
otelCollectorStatus: "connected",
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
if (extra?.osType) {
|
|
144
|
+
data.osType = extra.osType;
|
|
145
|
+
}
|
|
146
|
+
if (extra?.osVersion) {
|
|
147
|
+
data.osVersion = extra.osVersion;
|
|
148
|
+
}
|
|
149
|
+
if (extra?.hostId) {
|
|
150
|
+
data.hostId = extra.hostId;
|
|
151
|
+
}
|
|
152
|
+
if (extra?.hostArch) {
|
|
153
|
+
data.hostArch = extra.hostArch;
|
|
154
|
+
}
|
|
155
|
+
if (extra?.hostType) {
|
|
156
|
+
data.hostType = extra.hostType;
|
|
157
|
+
}
|
|
158
|
+
if (extra?.hostIpAddresses) {
|
|
159
|
+
data.hostIpAddresses = extra.hostIpAddresses;
|
|
160
|
+
}
|
|
161
|
+
if (extra?.cpuCores !== undefined) {
|
|
162
|
+
data.cpuCores = extra.cpuCores;
|
|
163
|
+
}
|
|
164
|
+
if (extra?.totalMemoryBytes !== undefined) {
|
|
165
|
+
data.totalMemoryBytes = extra.totalMemoryBytes;
|
|
166
|
+
}
|
|
167
|
+
if (extra?.processCount !== undefined) {
|
|
168
|
+
data.processCount = extra.processCount;
|
|
169
|
+
}
|
|
170
|
+
if (extra?.containerRuntime) {
|
|
171
|
+
data.containerRuntime = extra.containerRuntime;
|
|
172
|
+
}
|
|
173
|
+
if (extra?.dockerHostId) {
|
|
174
|
+
data.dockerHostId = extra.dockerHostId;
|
|
175
|
+
}
|
|
176
|
+
if (extra?.kubernetesClusterId) {
|
|
177
|
+
data.kubernetesClusterId = extra.kubernetesClusterId;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
await this.updateOneById({
|
|
181
|
+
id: hostId,
|
|
182
|
+
data: data,
|
|
183
|
+
props: {
|
|
184
|
+
isRoot: true,
|
|
185
|
+
},
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
@CaptureSpan()
|
|
190
|
+
public async markDisconnectedHosts(): Promise<void> {
|
|
191
|
+
const fiveMinutesAgo: Date = OneUptimeDate.addRemoveMinutes(
|
|
192
|
+
OneUptimeDate.getCurrentDate(),
|
|
193
|
+
-5,
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
const connectedHosts: Array<Model> = await this.findBy({
|
|
197
|
+
query: {
|
|
198
|
+
otelCollectorStatus: "connected",
|
|
199
|
+
lastSeenAt: QueryHelper.lessThan(fiveMinutesAgo),
|
|
200
|
+
},
|
|
201
|
+
select: {
|
|
202
|
+
_id: true,
|
|
203
|
+
},
|
|
204
|
+
limit: LIMIT_MAX,
|
|
205
|
+
skip: 0,
|
|
206
|
+
props: {
|
|
207
|
+
isRoot: true,
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
for (const host of connectedHosts) {
|
|
212
|
+
if (host._id) {
|
|
213
|
+
await this.updateOneById({
|
|
214
|
+
id: new ObjectID(host._id.toString()),
|
|
215
|
+
data: {
|
|
216
|
+
otelCollectorStatus: "disconnected",
|
|
217
|
+
},
|
|
218
|
+
props: {
|
|
219
|
+
isRoot: true,
|
|
220
|
+
},
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export default new Service();
|
|
@@ -669,14 +669,21 @@ export class LogAggregationService {
|
|
|
669
669
|
for (const [attrKey, attrValue] of Object.entries(request.attributes)) {
|
|
670
670
|
LogAggregationService.validateFacetKey(attrKey);
|
|
671
671
|
|
|
672
|
+
/*
|
|
673
|
+
* Match attribute keys case-insensitively — keys in the data come
|
|
674
|
+
* from many sources (OTEL conventions are dot.lowercase, app code
|
|
675
|
+
* often uses camelCase like `requestId`), and forcing users to
|
|
676
|
+
* remember the exact casing is a poor experience. The user-supplied
|
|
677
|
+
* key is validated above.
|
|
678
|
+
*/
|
|
672
679
|
statement.append(
|
|
673
|
-
SQL` AND
|
|
680
|
+
SQL` AND arrayExists((k, v) -> lowerUTF8(k) = lowerUTF8(${{
|
|
674
681
|
type: TableColumnType.Text,
|
|
675
682
|
value: attrKey,
|
|
676
|
-
}}
|
|
683
|
+
}}) AND v = ${{
|
|
677
684
|
type: TableColumnType.Text,
|
|
678
685
|
value: attrValue,
|
|
679
|
-
}}`,
|
|
686
|
+
}}, mapKeys(attributes), mapValues(attributes))`,
|
|
680
687
|
);
|
|
681
688
|
}
|
|
682
689
|
}
|