@oneuptime/common 10.0.52 → 10.0.54

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.
Files changed (405) hide show
  1. package/Models/AnalyticsModels/Metric.ts +78 -0
  2. package/Server/API/AIAgentDataAPI.ts +6 -1
  3. package/Server/API/BillingAPI.ts +28 -6
  4. package/Server/API/CommonAPI.ts +11 -0
  5. package/Server/API/DashboardAPI.ts +6 -2
  6. package/Server/API/DashboardDomainAPI.ts +10 -3
  7. package/Server/API/GitHubAPI.ts +58 -14
  8. package/Server/API/MicrosoftTeamsAPI.ts +97 -33
  9. package/Server/API/OpenSourceDeploymentAPI.ts +2 -2
  10. package/Server/API/SlackAPI.ts +107 -36
  11. package/Server/API/StatusAPI.ts +37 -16
  12. package/Server/API/StatusPageAPI.ts +97 -23
  13. package/Server/API/StatusPageDomainAPI.ts +6 -3
  14. package/Server/API/TelemetryAPI.ts +81 -0
  15. package/Server/API/UserAPI.ts +3 -3
  16. package/Server/API/UserCallAPI.ts +5 -2
  17. package/Server/API/UserEmailAPI.ts +5 -2
  18. package/Server/API/UserPushAPI.ts +9 -3
  19. package/Server/API/UserSmsAPI.ts +5 -2
  20. package/Server/API/UserWhatsAppAPI.ts +5 -2
  21. package/Server/Infrastructure/Postgres/SchemaMigrations/1774559064921-MigrationName.ts +47 -0
  22. package/Server/Infrastructure/Postgres/SchemaMigrations/1775735059360-MigrationName.ts +35 -0
  23. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +4 -0
  24. package/Server/Middleware/NotificationMiddleware.ts +2 -2
  25. package/Server/Middleware/ProjectAuthorization.ts +6 -0
  26. package/Server/Middleware/SCIMAuthorization.ts +2 -1
  27. package/Server/Middleware/SlackAuthorization.ts +28 -10
  28. package/Server/Middleware/TelemetryIngest.ts +16 -3
  29. package/Server/Middleware/UserAuthorization.ts +22 -5
  30. package/Server/Middleware/WhatsAppAuthorization.ts +15 -4
  31. package/Server/Services/AIAgentService.ts +13 -6
  32. package/Server/Services/AIService.ts +9 -3
  33. package/Server/Services/AlertEpisodeFeedService.ts +17 -5
  34. package/Server/Services/AlertEpisodeService.ts +34 -3
  35. package/Server/Services/AlertEpisodeStateTimelineService.ts +80 -22
  36. package/Server/Services/AlertFeedService.ts +17 -5
  37. package/Server/Services/AlertGroupingEngineService.ts +36 -7
  38. package/Server/Services/AlertService.ts +60 -8
  39. package/Server/Services/AlertStateTimelineService.ts +29 -7
  40. package/Server/Services/AnalyticsDatabaseService.ts +59 -25
  41. package/Server/Services/BillingInvoiceService.ts +7 -3
  42. package/Server/Services/BillingService.ts +9 -2
  43. package/Server/Services/DashboardDomainService.ts +56 -22
  44. package/Server/Services/DashboardService.ts +11 -4
  45. package/Server/Services/DatabaseService.ts +31 -11
  46. package/Server/Services/IncidentEpisodeFeedService.ts +17 -5
  47. package/Server/Services/IncidentEpisodeService.ts +34 -3
  48. package/Server/Services/IncidentEpisodeStateTimelineService.ts +80 -22
  49. package/Server/Services/IncidentFeedService.ts +33 -9
  50. package/Server/Services/IncidentGroupingEngineService.ts +35 -6
  51. package/Server/Services/IncidentService.ts +103 -9
  52. package/Server/Services/IncidentSlaRuleService.ts +16 -4
  53. package/Server/Services/IncidentSlaService.ts +20 -4
  54. package/Server/Services/IncidentStateTimelineService.ts +120 -31
  55. package/Server/Services/KubernetesClusterService.ts +62 -14
  56. package/Server/Services/LabelService.ts +14 -1
  57. package/Server/Services/MonitorFeedService.ts +33 -9
  58. package/Server/Services/MonitorProbeService.ts +31 -2
  59. package/Server/Services/MonitorService.ts +35 -4
  60. package/Server/Services/MonitorStatusTimelineService.ts +68 -20
  61. package/Server/Services/NotificationService.ts +4 -2
  62. package/Server/Services/OnCallDutyPolicyEscalationRuleService.ts +53 -9
  63. package/Server/Services/OnCallDutyPolicyEscalationRuleUserService.ts +9 -2
  64. package/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.ts +29 -8
  65. package/Server/Services/OnCallDutyPolicyFeedService.ts +33 -8
  66. package/Server/Services/OnCallDutyPolicyScheduleService.ts +97 -24
  67. package/Server/Services/OnCallDutyPolicyService.ts +2 -1
  68. package/Server/Services/OpenTelemetryIngestService.ts +51 -20
  69. package/Server/Services/ProbeService.ts +16 -7
  70. package/Server/Services/ProjectService.ts +29 -11
  71. package/Server/Services/ScheduledMaintenanceFeedService.ts +17 -4
  72. package/Server/Services/ScheduledMaintenanceService.ts +52 -6
  73. package/Server/Services/ScheduledMaintenanceStateTimelineService.ts +72 -20
  74. package/Server/Services/StatusPageDomainService.ts +59 -23
  75. package/Server/Services/StatusPageService.ts +26 -8
  76. package/Server/Services/StatusPageSubscriberService.ts +382 -111
  77. package/Server/Services/TeamMemberService.ts +9 -3
  78. package/Server/Services/TelemetryAttributeService.ts +117 -4
  79. package/Server/Services/UserNotificationRuleService.ts +9 -3
  80. package/Server/Services/UserService.ts +6 -4
  81. package/Server/Services/UserWhatsAppService.ts +9 -3
  82. package/Server/Services/WorkflowService.ts +7 -3
  83. package/Server/Services/WorkspaceNotificationRuleService.ts +398 -156
  84. package/Server/Types/Domain.ts +15 -5
  85. package/Server/Types/Workflow/Components/API/Post.ts +22 -8
  86. package/Server/Types/Workflow/Components/BaseModel/OnTriggerBaseModel.ts +12 -4
  87. package/Server/Utils/AnalyticsDatabase/StatementGenerator.ts +10 -0
  88. package/Server/Utils/CodeRepository/CodeRepository.ts +62 -13
  89. package/Server/Utils/Express.ts +1 -0
  90. package/Server/Utils/Greenlock/Greenlock.ts +75 -20
  91. package/Server/Utils/LLM/LLMService.ts +22 -7
  92. package/Server/Utils/Logger.ts +93 -13
  93. package/Server/Utils/Monitor/MonitorAlert.ts +15 -3
  94. package/Server/Utils/Monitor/MonitorCriteriaEvaluator.ts +15 -5
  95. package/Server/Utils/Monitor/MonitorIncident.ts +17 -3
  96. package/Server/Utils/Monitor/MonitorStatusTimeline.ts +6 -1
  97. package/Server/Utils/Profiling.ts +11 -5
  98. package/Server/Utils/Realtime.ts +90 -31
  99. package/Server/Utils/Response.ts +2 -2
  100. package/Server/Utils/StartServer.ts +43 -9
  101. package/Server/Utils/Telemetry/SpanUtil.ts +90 -0
  102. package/Server/Utils/Workspace/MicrosoftTeams/Actions/Alert.ts +58 -15
  103. package/Server/Utils/Workspace/MicrosoftTeams/Actions/AlertEpisode.ts +58 -15
  104. package/Server/Utils/Workspace/MicrosoftTeams/Actions/Auth.ts +19 -3
  105. package/Server/Utils/Workspace/MicrosoftTeams/Actions/Incident.ts +87 -22
  106. package/Server/Utils/Workspace/MicrosoftTeams/Actions/Monitor.ts +12 -3
  107. package/Server/Utils/Workspace/MicrosoftTeams/Actions/OnCallDutyPolicy.ts +25 -7
  108. package/Server/Utils/Workspace/MicrosoftTeams/Actions/ScheduledMaintenance.ts +55 -8
  109. package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.ts +100 -22
  110. package/Server/Utils/Workspace/Slack/Actions/Alert.ts +35 -9
  111. package/Server/Utils/Workspace/Slack/Actions/AlertEpisode.ts +32 -8
  112. package/Server/Utils/Workspace/Slack/Actions/Auth.ts +3 -1
  113. package/Server/Utils/Workspace/Slack/Actions/Incident.ts +52 -11
  114. package/Server/Utils/Workspace/Slack/Actions/IncidentEpisode.ts +4 -1
  115. package/Server/Utils/Workspace/Slack/Actions/ScheduledMaintenance.ts +89 -20
  116. package/Server/Utils/Workspace/Slack/Slack.ts +498 -247
  117. package/Server/Utils/Workspace/Workspace.ts +33 -11
  118. package/Server/Utils/Workspace/WorkspaceBase.ts +3 -1
  119. package/Server/Utils/Workspace/WorkspaceMessages/Alert.ts +8 -2
  120. package/Tests/Server/Middleware/UserAuthorization.test.ts +1 -1
  121. package/Tests/Server/Services/AnalyticsDatabaseService.test.ts +12 -3
  122. package/UI/Components/BulkUpdate/BulkUpdateForm.tsx +60 -38
  123. package/UI/Components/Charts/Area/AreaChart.tsx +35 -1
  124. package/UI/Components/Charts/ChartGroup/ChartGroup.tsx +7 -0
  125. package/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.tsx +33 -0
  126. package/UI/Components/Charts/ChartLibrary/LineChart/LineChart.tsx +33 -0
  127. package/UI/Components/Charts/ChartLibrary/Types/FormattedExemplarPoint.ts +14 -0
  128. package/UI/Components/Charts/Line/LineChart.tsx +35 -1
  129. package/UI/Components/Charts/Types/ExemplarPoint.ts +6 -0
  130. package/UI/Components/Dictionary/Dictionary.tsx +13 -1
  131. package/UI/Components/Filters/FiltersForm.tsx +2 -0
  132. package/UI/Components/Filters/JSONFilter.tsx +5 -1
  133. package/UI/Components/Filters/Types/Filter.ts +2 -0
  134. package/UI/Components/Markdown.tsx/MarkdownViewer.tsx +3 -3
  135. package/UI/Components/ModelTable/BaseModelTable.tsx +10 -6
  136. package/UI/Components/Navbar/NavBar.tsx +10 -0
  137. package/build/dist/Models/AnalyticsModels/Metric.js +70 -0
  138. package/build/dist/Models/AnalyticsModels/Metric.js.map +1 -1
  139. package/build/dist/Server/API/AIAgentDataAPI.js +6 -6
  140. package/build/dist/Server/API/AIAgentDataAPI.js.map +1 -1
  141. package/build/dist/Server/API/BillingAPI.js +13 -13
  142. package/build/dist/Server/API/BillingAPI.js.map +1 -1
  143. package/build/dist/Server/API/CommonAPI.js +5 -0
  144. package/build/dist/Server/API/CommonAPI.js.map +1 -1
  145. package/build/dist/Server/API/DashboardAPI.js +2 -2
  146. package/build/dist/Server/API/DashboardAPI.js.map +1 -1
  147. package/build/dist/Server/API/DashboardDomainAPI.js +3 -3
  148. package/build/dist/Server/API/DashboardDomainAPI.js.map +1 -1
  149. package/build/dist/Server/API/GitHubAPI.js +19 -19
  150. package/build/dist/Server/API/GitHubAPI.js.map +1 -1
  151. package/build/dist/Server/API/MicrosoftTeamsAPI.js +34 -34
  152. package/build/dist/Server/API/MicrosoftTeamsAPI.js.map +1 -1
  153. package/build/dist/Server/API/OpenSourceDeploymentAPI.js +2 -2
  154. package/build/dist/Server/API/OpenSourceDeploymentAPI.js.map +1 -1
  155. package/build/dist/Server/API/SlackAPI.js +38 -38
  156. package/build/dist/Server/API/SlackAPI.js.map +1 -1
  157. package/build/dist/Server/API/StatusAPI.js +16 -16
  158. package/build/dist/Server/API/StatusAPI.js.map +1 -1
  159. package/build/dist/Server/API/StatusPageAPI.js +52 -52
  160. package/build/dist/Server/API/StatusPageAPI.js.map +1 -1
  161. package/build/dist/Server/API/StatusPageDomainAPI.js +3 -3
  162. package/build/dist/Server/API/StatusPageDomainAPI.js.map +1 -1
  163. package/build/dist/Server/API/TelemetryAPI.js +39 -0
  164. package/build/dist/Server/API/TelemetryAPI.js.map +1 -1
  165. package/build/dist/Server/API/UserAPI.js +3 -3
  166. package/build/dist/Server/API/UserAPI.js.map +1 -1
  167. package/build/dist/Server/API/UserCallAPI.js +2 -2
  168. package/build/dist/Server/API/UserCallAPI.js.map +1 -1
  169. package/build/dist/Server/API/UserEmailAPI.js +2 -2
  170. package/build/dist/Server/API/UserEmailAPI.js.map +1 -1
  171. package/build/dist/Server/API/UserPushAPI.js +3 -3
  172. package/build/dist/Server/API/UserPushAPI.js.map +1 -1
  173. package/build/dist/Server/API/UserSmsAPI.js +2 -2
  174. package/build/dist/Server/API/UserSmsAPI.js.map +1 -1
  175. package/build/dist/Server/API/UserWhatsAppAPI.js +2 -2
  176. package/build/dist/Server/API/UserWhatsAppAPI.js.map +1 -1
  177. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774559064921-MigrationName.js +40 -0
  178. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774559064921-MigrationName.js.map +1 -0
  179. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1775735059360-MigrationName.js +18 -0
  180. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1775735059360-MigrationName.js.map +1 -0
  181. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +4 -0
  182. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  183. package/build/dist/Server/Middleware/NotificationMiddleware.js +2 -2
  184. package/build/dist/Server/Middleware/NotificationMiddleware.js.map +1 -1
  185. package/build/dist/Server/Middleware/ProjectAuthorization.js +5 -0
  186. package/build/dist/Server/Middleware/ProjectAuthorization.js.map +1 -1
  187. package/build/dist/Server/Middleware/SCIMAuthorization.js +2 -2
  188. package/build/dist/Server/Middleware/SCIMAuthorization.js.map +1 -1
  189. package/build/dist/Server/Middleware/SlackAuthorization.js +10 -10
  190. package/build/dist/Server/Middleware/SlackAuthorization.js.map +1 -1
  191. package/build/dist/Server/Middleware/TelemetryIngest.js +9 -4
  192. package/build/dist/Server/Middleware/TelemetryIngest.js.map +1 -1
  193. package/build/dist/Server/Middleware/UserAuthorization.js +10 -5
  194. package/build/dist/Server/Middleware/UserAuthorization.js.map +1 -1
  195. package/build/dist/Server/Middleware/WhatsAppAuthorization.js +6 -6
  196. package/build/dist/Server/Middleware/WhatsAppAuthorization.js.map +1 -1
  197. package/build/dist/Server/Services/AIAgentService.js +13 -7
  198. package/build/dist/Server/Services/AIAgentService.js.map +1 -1
  199. package/build/dist/Server/Services/AIService.js +9 -2
  200. package/build/dist/Server/Services/AIService.js.map +1 -1
  201. package/build/dist/Server/Services/AlertEpisodeFeedService.js +17 -5
  202. package/build/dist/Server/Services/AlertEpisodeFeedService.js.map +1 -1
  203. package/build/dist/Server/Services/AlertEpisodeService.js +40 -10
  204. package/build/dist/Server/Services/AlertEpisodeService.js.map +1 -1
  205. package/build/dist/Server/Services/AlertEpisodeStateTimelineService.js +81 -24
  206. package/build/dist/Server/Services/AlertEpisodeStateTimelineService.js.map +1 -1
  207. package/build/dist/Server/Services/AlertFeedService.js +17 -5
  208. package/build/dist/Server/Services/AlertFeedService.js.map +1 -1
  209. package/build/dist/Server/Services/AlertGroupingEngineService.js +44 -28
  210. package/build/dist/Server/Services/AlertGroupingEngineService.js.map +1 -1
  211. package/build/dist/Server/Services/AlertService.js +72 -20
  212. package/build/dist/Server/Services/AlertService.js.map +1 -1
  213. package/build/dist/Server/Services/AlertStateTimelineService.js +36 -13
  214. package/build/dist/Server/Services/AlertStateTimelineService.js.map +1 -1
  215. package/build/dist/Server/Services/AnalyticsDatabaseService.js +52 -28
  216. package/build/dist/Server/Services/AnalyticsDatabaseService.js.map +1 -1
  217. package/build/dist/Server/Services/BillingInvoiceService.js +7 -2
  218. package/build/dist/Server/Services/BillingInvoiceService.js.map +1 -1
  219. package/build/dist/Server/Services/BillingService.js +8 -8
  220. package/build/dist/Server/Services/BillingService.js.map +1 -1
  221. package/build/dist/Server/Services/DashboardDomainService.js +49 -27
  222. package/build/dist/Server/Services/DashboardDomainService.js.map +1 -1
  223. package/build/dist/Server/Services/DashboardService.js +11 -4
  224. package/build/dist/Server/Services/DashboardService.js.map +1 -1
  225. package/build/dist/Server/Services/DatabaseService.js +32 -12
  226. package/build/dist/Server/Services/DatabaseService.js.map +1 -1
  227. package/build/dist/Server/Services/IncidentEpisodeFeedService.js +17 -5
  228. package/build/dist/Server/Services/IncidentEpisodeFeedService.js.map +1 -1
  229. package/build/dist/Server/Services/IncidentEpisodeService.js +40 -10
  230. package/build/dist/Server/Services/IncidentEpisodeService.js.map +1 -1
  231. package/build/dist/Server/Services/IncidentEpisodeStateTimelineService.js +81 -24
  232. package/build/dist/Server/Services/IncidentEpisodeStateTimelineService.js.map +1 -1
  233. package/build/dist/Server/Services/IncidentFeedService.js +34 -10
  234. package/build/dist/Server/Services/IncidentFeedService.js.map +1 -1
  235. package/build/dist/Server/Services/IncidentGroupingEngineService.js +43 -29
  236. package/build/dist/Server/Services/IncidentGroupingEngineService.js.map +1 -1
  237. package/build/dist/Server/Services/IncidentService.js +116 -28
  238. package/build/dist/Server/Services/IncidentService.js.map +1 -1
  239. package/build/dist/Server/Services/IncidentSlaRuleService.js +19 -11
  240. package/build/dist/Server/Services/IncidentSlaRuleService.js.map +1 -1
  241. package/build/dist/Server/Services/IncidentSlaService.js +21 -14
  242. package/build/dist/Server/Services/IncidentSlaService.js.map +1 -1
  243. package/build/dist/Server/Services/IncidentStateTimelineService.js +130 -37
  244. package/build/dist/Server/Services/IncidentStateTimelineService.js.map +1 -1
  245. package/build/dist/Server/Services/KubernetesClusterService.js +51 -14
  246. package/build/dist/Server/Services/KubernetesClusterService.js.map +1 -1
  247. package/build/dist/Server/Services/LabelService.js +10 -1
  248. package/build/dist/Server/Services/LabelService.js.map +1 -1
  249. package/build/dist/Server/Services/MonitorFeedService.js +34 -10
  250. package/build/dist/Server/Services/MonitorFeedService.js.map +1 -1
  251. package/build/dist/Server/Services/MonitorProbeService.js +23 -3
  252. package/build/dist/Server/Services/MonitorProbeService.js.map +1 -1
  253. package/build/dist/Server/Services/MonitorService.js +42 -11
  254. package/build/dist/Server/Services/MonitorService.js.map +1 -1
  255. package/build/dist/Server/Services/MonitorStatusTimelineService.js +69 -21
  256. package/build/dist/Server/Services/MonitorStatusTimelineService.js.map +1 -1
  257. package/build/dist/Server/Services/NotificationService.js +4 -3
  258. package/build/dist/Server/Services/NotificationService.js.map +1 -1
  259. package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleService.js +49 -12
  260. package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleService.js.map +1 -1
  261. package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleUserService.js +9 -3
  262. package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleUserService.js.map +1 -1
  263. package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.js +26 -11
  264. package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.js.map +1 -1
  265. package/build/dist/Server/Services/OnCallDutyPolicyFeedService.js +34 -10
  266. package/build/dist/Server/Services/OnCallDutyPolicyFeedService.js.map +1 -1
  267. package/build/dist/Server/Services/OnCallDutyPolicyScheduleService.js +94 -37
  268. package/build/dist/Server/Services/OnCallDutyPolicyScheduleService.js.map +1 -1
  269. package/build/dist/Server/Services/OnCallDutyPolicyService.js +1 -1
  270. package/build/dist/Server/Services/OnCallDutyPolicyService.js.map +1 -1
  271. package/build/dist/Server/Services/OpenTelemetryIngestService.js +45 -17
  272. package/build/dist/Server/Services/OpenTelemetryIngestService.js.map +1 -1
  273. package/build/dist/Server/Services/ProbeService.js +13 -7
  274. package/build/dist/Server/Services/ProbeService.js.map +1 -1
  275. package/build/dist/Server/Services/ProjectService.js +41 -21
  276. package/build/dist/Server/Services/ProjectService.js.map +1 -1
  277. package/build/dist/Server/Services/ScheduledMaintenanceFeedService.js +17 -5
  278. package/build/dist/Server/Services/ScheduledMaintenanceFeedService.js.map +1 -1
  279. package/build/dist/Server/Services/ScheduledMaintenanceService.js +71 -24
  280. package/build/dist/Server/Services/ScheduledMaintenanceService.js.map +1 -1
  281. package/build/dist/Server/Services/ScheduledMaintenanceStateTimelineService.js +72 -24
  282. package/build/dist/Server/Services/ScheduledMaintenanceStateTimelineService.js.map +1 -1
  283. package/build/dist/Server/Services/StatusPageDomainService.js +55 -29
  284. package/build/dist/Server/Services/StatusPageDomainService.js.map +1 -1
  285. package/build/dist/Server/Services/StatusPageService.js +29 -9
  286. package/build/dist/Server/Services/StatusPageService.js.map +1 -1
  287. package/build/dist/Server/Services/StatusPageSubscriberService.js +393 -130
  288. package/build/dist/Server/Services/StatusPageSubscriberService.js.map +1 -1
  289. package/build/dist/Server/Services/TeamMemberService.js +10 -2
  290. package/build/dist/Server/Services/TeamMemberService.js.map +1 -1
  291. package/build/dist/Server/Services/TelemetryAttributeService.js +83 -6
  292. package/build/dist/Server/Services/TelemetryAttributeService.js.map +1 -1
  293. package/build/dist/Server/Services/UserNotificationRuleService.js +10 -2
  294. package/build/dist/Server/Services/UserNotificationRuleService.js.map +1 -1
  295. package/build/dist/Server/Services/UserService.js +8 -3
  296. package/build/dist/Server/Services/UserService.js.map +1 -1
  297. package/build/dist/Server/Services/UserWhatsAppService.js +10 -2
  298. package/build/dist/Server/Services/UserWhatsAppService.js.map +1 -1
  299. package/build/dist/Server/Services/WorkflowService.js +7 -2
  300. package/build/dist/Server/Services/WorkflowService.js.map +1 -1
  301. package/build/dist/Server/Services/WorkspaceNotificationRuleService.js +367 -180
  302. package/build/dist/Server/Services/WorkspaceNotificationRuleService.js.map +1 -1
  303. package/build/dist/Server/Types/Domain.js +12 -6
  304. package/build/dist/Server/Types/Domain.js.map +1 -1
  305. package/build/dist/Server/Types/Workflow/Components/API/Post.js +11 -7
  306. package/build/dist/Server/Types/Workflow/Components/API/Post.js.map +1 -1
  307. package/build/dist/Server/Types/Workflow/Components/BaseModel/OnTriggerBaseModel.js +11 -4
  308. package/build/dist/Server/Types/Workflow/Components/BaseModel/OnTriggerBaseModel.js.map +1 -1
  309. package/build/dist/Server/Utils/AnalyticsDatabase/StatementGenerator.js +7 -0
  310. package/build/dist/Server/Utils/AnalyticsDatabase/StatementGenerator.js.map +1 -1
  311. package/build/dist/Server/Utils/CodeRepository/CodeRepository.js +45 -17
  312. package/build/dist/Server/Utils/CodeRepository/CodeRepository.js.map +1 -1
  313. package/build/dist/Server/Utils/Express.js.map +1 -1
  314. package/build/dist/Server/Utils/Greenlock/Greenlock.js +36 -29
  315. package/build/dist/Server/Utils/Greenlock/Greenlock.js.map +1 -1
  316. package/build/dist/Server/Utils/LLM/LLMService.js +18 -6
  317. package/build/dist/Server/Utils/LLM/LLMService.js.map +1 -1
  318. package/build/dist/Server/Utils/Logger.js +61 -13
  319. package/build/dist/Server/Utils/Logger.js.map +1 -1
  320. package/build/dist/Server/Utils/Monitor/MonitorAlert.js +23 -20
  321. package/build/dist/Server/Utils/Monitor/MonitorAlert.js.map +1 -1
  322. package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js +13 -4
  323. package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js.map +1 -1
  324. package/build/dist/Server/Utils/Monitor/MonitorIncident.js +25 -22
  325. package/build/dist/Server/Utils/Monitor/MonitorIncident.js.map +1 -1
  326. package/build/dist/Server/Utils/Monitor/MonitorStatusTimeline.js +6 -3
  327. package/build/dist/Server/Utils/Monitor/MonitorStatusTimeline.js.map +1 -1
  328. package/build/dist/Server/Utils/Profiling.js +9 -6
  329. package/build/dist/Server/Utils/Profiling.js.map +1 -1
  330. package/build/dist/Server/Utils/Realtime.js +50 -34
  331. package/build/dist/Server/Utils/Realtime.js.map +1 -1
  332. package/build/dist/Server/Utils/Response.js +2 -2
  333. package/build/dist/Server/Utils/Response.js.map +1 -1
  334. package/build/dist/Server/Utils/StartServer.js +23 -11
  335. package/build/dist/Server/Utils/StartServer.js.map +1 -1
  336. package/build/dist/Server/Utils/Telemetry/SpanUtil.js +52 -0
  337. package/build/dist/Server/Utils/Telemetry/SpanUtil.js.map +1 -0
  338. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Alert.js +58 -15
  339. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Alert.js.map +1 -1
  340. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/AlertEpisode.js +58 -15
  341. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/AlertEpisode.js.map +1 -1
  342. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Auth.js +19 -5
  343. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Auth.js.map +1 -1
  344. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Incident.js +90 -26
  345. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Incident.js.map +1 -1
  346. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Monitor.js +12 -3
  347. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Monitor.js.map +1 -1
  348. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/OnCallDutyPolicy.js +25 -7
  349. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/OnCallDutyPolicy.js.map +1 -1
  350. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/ScheduledMaintenance.js +58 -19
  351. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/ScheduledMaintenance.js.map +1 -1
  352. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js +102 -29
  353. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js.map +1 -1
  354. package/build/dist/Server/Utils/Workspace/Slack/Actions/Alert.js +38 -9
  355. package/build/dist/Server/Utils/Workspace/Slack/Actions/Alert.js.map +1 -1
  356. package/build/dist/Server/Utils/Workspace/Slack/Actions/AlertEpisode.js +34 -8
  357. package/build/dist/Server/Utils/Workspace/Slack/Actions/AlertEpisode.js.map +1 -1
  358. package/build/dist/Server/Utils/Workspace/Slack/Actions/Auth.js +3 -1
  359. package/build/dist/Server/Utils/Workspace/Slack/Actions/Auth.js.map +1 -1
  360. package/build/dist/Server/Utils/Workspace/Slack/Actions/Incident.js +55 -13
  361. package/build/dist/Server/Utils/Workspace/Slack/Actions/Incident.js.map +1 -1
  362. package/build/dist/Server/Utils/Workspace/Slack/Actions/IncidentEpisode.js +5 -1
  363. package/build/dist/Server/Utils/Workspace/Slack/Actions/IncidentEpisode.js.map +1 -1
  364. package/build/dist/Server/Utils/Workspace/Slack/Actions/ScheduledMaintenance.js +91 -26
  365. package/build/dist/Server/Utils/Workspace/Slack/Actions/ScheduledMaintenance.js.map +1 -1
  366. package/build/dist/Server/Utils/Workspace/Slack/Slack.js +355 -270
  367. package/build/dist/Server/Utils/Workspace/Slack/Slack.js.map +1 -1
  368. package/build/dist/Server/Utils/Workspace/Workspace.js +21 -12
  369. package/build/dist/Server/Utils/Workspace/Workspace.js.map +1 -1
  370. package/build/dist/Server/Utils/Workspace/WorkspaceBase.js +3 -1
  371. package/build/dist/Server/Utils/Workspace/WorkspaceBase.js.map +1 -1
  372. package/build/dist/Server/Utils/Workspace/WorkspaceMessages/Alert.js +9 -2
  373. package/build/dist/Server/Utils/Workspace/WorkspaceMessages/Alert.js.map +1 -1
  374. package/build/dist/Tests/Server/Middleware/UserAuthorization.test.js +1 -1
  375. package/build/dist/Tests/Server/Middleware/UserAuthorization.test.js.map +1 -1
  376. package/build/dist/Tests/Server/Services/AnalyticsDatabaseService.test.js +12 -6
  377. package/build/dist/Tests/Server/Services/AnalyticsDatabaseService.test.js.map +1 -1
  378. package/build/dist/UI/Components/BulkUpdate/BulkUpdateForm.js +31 -30
  379. package/build/dist/UI/Components/BulkUpdate/BulkUpdateForm.js.map +1 -1
  380. package/build/dist/UI/Components/Charts/Area/AreaChart.js +20 -2
  381. package/build/dist/UI/Components/Charts/Area/AreaChart.js.map +1 -1
  382. package/build/dist/UI/Components/Charts/ChartGroup/ChartGroup.js +2 -2
  383. package/build/dist/UI/Components/Charts/ChartGroup/ChartGroup.js.map +1 -1
  384. package/build/dist/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.js +9 -2
  385. package/build/dist/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.js.map +1 -1
  386. package/build/dist/UI/Components/Charts/ChartLibrary/LineChart/LineChart.js +9 -2
  387. package/build/dist/UI/Components/Charts/ChartLibrary/LineChart/LineChart.js.map +1 -1
  388. package/build/dist/UI/Components/Charts/ChartLibrary/Types/FormattedExemplarPoint.js +2 -0
  389. package/build/dist/UI/Components/Charts/ChartLibrary/Types/FormattedExemplarPoint.js.map +1 -0
  390. package/build/dist/UI/Components/Charts/Line/LineChart.js +20 -2
  391. package/build/dist/UI/Components/Charts/Line/LineChart.js.map +1 -1
  392. package/build/dist/UI/Components/Charts/Types/ExemplarPoint.js +2 -0
  393. package/build/dist/UI/Components/Charts/Types/ExemplarPoint.js.map +1 -0
  394. package/build/dist/UI/Components/Dictionary/Dictionary.js +9 -1
  395. package/build/dist/UI/Components/Dictionary/Dictionary.js.map +1 -1
  396. package/build/dist/UI/Components/Filters/FiltersForm.js +1 -1
  397. package/build/dist/UI/Components/Filters/FiltersForm.js.map +1 -1
  398. package/build/dist/UI/Components/Filters/JSONFilter.js +1 -1
  399. package/build/dist/UI/Components/Filters/JSONFilter.js.map +1 -1
  400. package/build/dist/UI/Components/Markdown.tsx/MarkdownViewer.js +3 -3
  401. package/build/dist/UI/Components/ModelTable/BaseModelTable.js +9 -5
  402. package/build/dist/UI/Components/ModelTable/BaseModelTable.js.map +1 -1
  403. package/build/dist/UI/Components/Navbar/NavBar.js +9 -1
  404. package/build/dist/UI/Components/Navbar/NavBar.js.map +1 -1
  405. package/package.json +1 -1
@@ -24,7 +24,7 @@ import IncidentStateTimeline from "../../Models/DatabaseModels/IncidentStateTime
24
24
  import IncidentMember from "../../Models/DatabaseModels/IncidentMember";
25
25
  import IncidentRole from "../../Models/DatabaseModels/IncidentRole";
26
26
  import { IsBillingEnabled } from "../EnvironmentConfig";
27
- import logger from "../Utils/Logger";
27
+ import logger, { LogAttributes } from "../Utils/Logger";
28
28
  import IncidentFeedService from "./IncidentFeedService";
29
29
  import { IncidentFeedEventType } from "../../Models/DatabaseModels/IncidentFeed";
30
30
  import CaptureSpan from "../Utils/Telemetry/CaptureSpan";
@@ -82,7 +82,10 @@ export class Service extends DatabaseService<IncidentStateTimeline> {
82
82
  namespace: "IncidentStateTimeline.create",
83
83
  });
84
84
  } catch (err) {
85
- logger.error(err);
85
+ logger.error(err, {
86
+ projectId: createBy.data.projectId?.toString(),
87
+ incidentId: createBy.data.incidentId?.toString(),
88
+ } as LogAttributes);
86
89
  }
87
90
 
88
91
  if (!createBy.data.startsAt) {
@@ -166,8 +169,14 @@ export class Service extends DatabaseService<IncidentStateTimeline> {
166
169
  }),
167
170
  ]);
168
171
 
169
- logger.debug("State Before this");
170
- logger.debug(stateBeforeThis);
172
+ logger.debug("State Before this", {
173
+ projectId: createBy.data.projectId?.toString(),
174
+ incidentId: createBy.data.incidentId?.toString(),
175
+ } as LogAttributes);
176
+ logger.debug(stateBeforeThis, {
177
+ projectId: createBy.data.projectId?.toString(),
178
+ incidentId: createBy.data.incidentId?.toString(),
179
+ } as LogAttributes);
171
180
 
172
181
  // If this is the first state, then do not notify the owner.
173
182
  if (!stateBeforeThis) {
@@ -246,8 +255,14 @@ export class Service extends DatabaseService<IncidentStateTimeline> {
246
255
  }
247
256
  }
248
257
 
249
- logger.debug("State After this");
250
- logger.debug(stateAfterThis);
258
+ logger.debug("State After this", {
259
+ projectId: createBy.data.projectId?.toString(),
260
+ incidentId: createBy.data.incidentId?.toString(),
261
+ } as LogAttributes);
262
+ logger.debug(stateAfterThis, {
263
+ projectId: createBy.data.projectId?.toString(),
264
+ incidentId: createBy.data.incidentId?.toString(),
265
+ } as LogAttributes);
251
266
 
252
267
  const publicNote: string | undefined = (
253
268
  createBy.miscDataProps as JSONObject | undefined
@@ -291,7 +306,10 @@ export class Service extends DatabaseService<IncidentStateTimeline> {
291
306
  try {
292
307
  await Semaphore.release(mutex);
293
308
  } catch (err) {
294
- logger.error(err);
309
+ logger.error(err, {
310
+ projectId: createBy.data.projectId?.toString(),
311
+ incidentId: createBy.data.incidentId?.toString(),
312
+ } as LogAttributes);
295
313
  }
296
314
  }
297
315
 
@@ -315,14 +333,32 @@ export class Service extends DatabaseService<IncidentStateTimeline> {
315
333
  }
316
334
  // update the last status as ended.
317
335
 
318
- logger.debug("Status Timeline Before this");
319
- logger.debug(onCreate.carryForward.statusTimelineBeforeThisStatus);
320
-
321
- logger.debug("Status Timeline After this");
322
- logger.debug(onCreate.carryForward.statusTimelineAfterThisStatus);
323
-
324
- logger.debug("Created Item");
325
- logger.debug(createdItem);
336
+ logger.debug("Status Timeline Before this", {
337
+ projectId: createdItem.projectId?.toString(),
338
+ incidentId: createdItem.incidentId?.toString(),
339
+ } as LogAttributes);
340
+ logger.debug(onCreate.carryForward.statusTimelineBeforeThisStatus, {
341
+ projectId: createdItem.projectId?.toString(),
342
+ incidentId: createdItem.incidentId?.toString(),
343
+ } as LogAttributes);
344
+
345
+ logger.debug("Status Timeline After this", {
346
+ projectId: createdItem.projectId?.toString(),
347
+ incidentId: createdItem.incidentId?.toString(),
348
+ } as LogAttributes);
349
+ logger.debug(onCreate.carryForward.statusTimelineAfterThisStatus, {
350
+ projectId: createdItem.projectId?.toString(),
351
+ incidentId: createdItem.incidentId?.toString(),
352
+ } as LogAttributes);
353
+
354
+ logger.debug("Created Item", {
355
+ projectId: createdItem.projectId?.toString(),
356
+ incidentId: createdItem.incidentId?.toString(),
357
+ } as LogAttributes);
358
+ logger.debug(createdItem, {
359
+ projectId: createdItem.projectId?.toString(),
360
+ incidentId: createdItem.incidentId?.toString(),
361
+ } as LogAttributes);
326
362
 
327
363
  /*
328
364
  * now there are three cases.
@@ -330,7 +366,10 @@ export class Service extends DatabaseService<IncidentStateTimeline> {
330
366
  */
331
367
  if (!onCreate.carryForward.statusTimelineBeforeThisStatus) {
332
368
  // This is the first status, no need to update previous status.
333
- logger.debug("This is the first status.");
369
+ logger.debug("This is the first status.", {
370
+ projectId: createdItem.projectId?.toString(),
371
+ incidentId: createdItem.incidentId?.toString(),
372
+ } as LogAttributes);
334
373
  } else if (!onCreate.carryForward.statusTimelineAfterThisStatus) {
335
374
  /*
336
375
  * 2. This is the last status.
@@ -345,7 +384,10 @@ export class Service extends DatabaseService<IncidentStateTimeline> {
345
384
  isRoot: true,
346
385
  },
347
386
  });
348
- logger.debug("This is the last status.");
387
+ logger.debug("This is the last status.", {
388
+ projectId: createdItem.projectId?.toString(),
389
+ incidentId: createdItem.incidentId?.toString(),
390
+ } as LogAttributes);
349
391
  } else {
350
392
  /*
351
393
  * 3. This is in the middle.
@@ -371,7 +413,10 @@ export class Service extends DatabaseService<IncidentStateTimeline> {
371
413
  isRoot: true,
372
414
  },
373
415
  });
374
- logger.debug("This status is in the middle.");
416
+ logger.debug("This status is in the middle.", {
417
+ projectId: createdItem.projectId?.toString(),
418
+ incidentId: createdItem.incidentId?.toString(),
419
+ } as LogAttributes);
375
420
  }
376
421
 
377
422
  if (!createdItem.endsAt) {
@@ -408,7 +453,10 @@ export class Service extends DatabaseService<IncidentStateTimeline> {
408
453
  try {
409
454
  await Semaphore.release(mutex);
410
455
  } catch (err) {
411
- logger.error(err);
456
+ logger.error(err, {
457
+ projectId: createdItem.projectId?.toString(),
458
+ incidentId: createdItem.incidentId?.toString(),
459
+ } as LogAttributes);
412
460
  }
413
461
  }
414
462
 
@@ -469,8 +517,14 @@ ${createdItem.rootCause}`,
469
517
  projectId: createdItem.projectId!,
470
518
  userId: stateChangeUserId,
471
519
  }).catch((error: Error) => {
472
- logger.error(`Error while auto-assigning incident commander:`);
473
- logger.error(error);
520
+ logger.error(`Error while auto-assigning incident commander:`, {
521
+ projectId: createdItem.projectId?.toString(),
522
+ incidentId: createdItem.incidentId?.toString(),
523
+ } as LogAttributes);
524
+ logger.error(error, {
525
+ projectId: createdItem.projectId?.toString(),
526
+ incidentId: createdItem.incidentId?.toString(),
527
+ } as LogAttributes);
474
528
  });
475
529
  }
476
530
 
@@ -523,8 +577,14 @@ ${createdItem.rootCause}`,
523
577
  IncidentService.refreshIncidentMetrics({
524
578
  incidentId: createdItem.incidentId,
525
579
  }).catch((error: Error) => {
526
- logger.error(`Error while refreshing incident metrics:`);
527
- logger.error(error);
580
+ logger.error(`Error while refreshing incident metrics:`, {
581
+ projectId: createdItem.projectId?.toString(),
582
+ incidentId: createdItem.incidentId?.toString(),
583
+ } as LogAttributes);
584
+ logger.error(error, {
585
+ projectId: createdItem.projectId?.toString(),
586
+ incidentId: createdItem.incidentId?.toString(),
587
+ } as LogAttributes);
528
588
  });
529
589
 
530
590
  // Track SLA response/resolution times
@@ -538,8 +598,14 @@ ${createdItem.rootCause}`,
538
598
  onCreate.carryForward.statusTimelineBeforeThisStatus?.incidentState
539
599
  ?.isResolvedState || false,
540
600
  }).catch((error: Error) => {
541
- logger.error(`Error while tracking SLA state change:`);
542
- logger.error(error);
601
+ logger.error(`Error while tracking SLA state change:`, {
602
+ projectId: createdItem.projectId?.toString(),
603
+ incidentId: createdItem.incidentId?.toString(),
604
+ } as LogAttributes);
605
+ logger.error(error, {
606
+ projectId: createdItem.projectId?.toString(),
607
+ incidentId: createdItem.incidentId?.toString(),
608
+ } as LogAttributes);
543
609
  });
544
610
 
545
611
  const isLastIncidentState: boolean = await this.isLastIncidentState({
@@ -563,8 +629,14 @@ ${createdItem.rootCause}`,
563
629
  ).toString()})** is resolved. Archiving channel.`,
564
630
  },
565
631
  }).catch((error: Error) => {
566
- logger.error(`Error while archiving workspace channels:`);
567
- logger.error(error);
632
+ logger.error(`Error while archiving workspace channels:`, {
633
+ projectId: createdItem.projectId?.toString(),
634
+ incidentId: createdItem.incidentId?.toString(),
635
+ } as LogAttributes);
636
+ logger.error(error, {
637
+ projectId: createdItem.projectId?.toString(),
638
+ incidentId: createdItem.incidentId?.toString(),
639
+ } as LogAttributes);
568
640
  });
569
641
  }
570
642
 
@@ -691,6 +763,10 @@ ${createdItem.rootCause}`,
691
763
 
692
764
  logger.debug(
693
765
  `Auto-assigned user ${data.userId.toString()} as Incident Commander for incident ${data.incidentId.toString()}`,
766
+ {
767
+ projectId: data.projectId?.toString(),
768
+ incidentId: data.incidentId?.toString(),
769
+ } as LogAttributes,
694
770
  );
695
771
  }
696
772
 
@@ -727,6 +803,10 @@ ${createdItem.rootCause}`,
727
803
 
728
804
  logger.info(
729
805
  `Created new SLA record for reopened incident ${data.incidentId}`,
806
+ {
807
+ projectId: data.projectId?.toString(),
808
+ incidentId: data.incidentId?.toString(),
809
+ } as LogAttributes,
730
810
  );
731
811
  }
732
812
 
@@ -749,7 +829,10 @@ ${createdItem.rootCause}`,
749
829
  });
750
830
  }
751
831
  } catch (error) {
752
- logger.error(`Error in trackSlaStateChange: ${error}`);
832
+ logger.error(`Error in trackSlaStateChange: ${error}`, {
833
+ projectId: data.projectId?.toString(),
834
+ incidentId: data.incidentId?.toString(),
835
+ } as LogAttributes);
753
836
  throw error;
754
837
  }
755
838
  }
@@ -847,7 +930,9 @@ ${createdItem.rootCause}`,
847
930
 
848
931
  if (!stateBeforeThis) {
849
932
  // This is the first state, no need to update previous state.
850
- logger.debug("This is the first state.");
933
+ logger.debug("This is the first state.", {
934
+ incidentId: incidentId?.toString(),
935
+ } as LogAttributes);
851
936
  } else if (!stateAfterThis) {
852
937
  /*
853
938
  * This is the last state.
@@ -862,7 +947,9 @@ ${createdItem.rootCause}`,
862
947
  isRoot: true,
863
948
  },
864
949
  });
865
- logger.debug("This is the last state.");
950
+ logger.debug("This is the last state.", {
951
+ incidentId: incidentId?.toString(),
952
+ } as LogAttributes);
866
953
  } else {
867
954
  /*
868
955
  * This state is in the middle.
@@ -888,7 +975,9 @@ ${createdItem.rootCause}`,
888
975
  isRoot: true,
889
976
  },
890
977
  });
891
- logger.debug("This state is in the middle.");
978
+ logger.debug("This state is in the middle.", {
979
+ incidentId: incidentId?.toString(),
980
+ } as LogAttributes);
892
981
  }
893
982
  }
894
983
 
@@ -5,6 +5,10 @@ import ObjectID from "../../Types/ObjectID";
5
5
  import QueryHelper from "../Types/Database/QueryHelper";
6
6
  import OneUptimeDate from "../../Types/Date";
7
7
  import LIMIT_MAX from "../../Types/Database/LimitMax";
8
+ import GlobalCache from "../Infrastructure/GlobalCache";
9
+
10
+ const LAST_SEEN_CACHE_NAMESPACE: string = "k8s-cluster-last-seen";
11
+ const LAST_SEEN_THROTTLE_SECONDS: number = 60;
8
12
 
9
13
  export class Service extends DatabaseService<Model> {
10
14
  public constructor() {
@@ -36,26 +40,70 @@ export class Service extends DatabaseService<Model> {
36
40
  return existingCluster;
37
41
  }
38
42
 
39
- // Create new cluster
40
- const newCluster: Model = new Model();
41
- newCluster.projectId = data.projectId;
42
- newCluster.name = data.clusterIdentifier;
43
- newCluster.clusterIdentifier = data.clusterIdentifier;
44
- newCluster.otelCollectorStatus = "connected";
45
- newCluster.lastSeenAt = OneUptimeDate.getCurrentDate();
43
+ try {
44
+ // Create new cluster
45
+ const newCluster: Model = new Model();
46
+ newCluster.projectId = data.projectId;
47
+ newCluster.name = data.clusterIdentifier;
48
+ newCluster.clusterIdentifier = data.clusterIdentifier;
49
+ newCluster.otelCollectorStatus = "connected";
50
+ newCluster.lastSeenAt = OneUptimeDate.getCurrentDate();
46
51
 
47
- const createdCluster: Model = await this.create({
48
- data: newCluster,
49
- props: {
50
- isRoot: true,
51
- },
52
- });
52
+ const createdCluster: Model = await this.create({
53
+ data: newCluster,
54
+ props: {
55
+ isRoot: true,
56
+ },
57
+ });
58
+
59
+ return createdCluster;
60
+ } catch {
61
+ /*
62
+ * Race condition: another request created the cluster concurrently.
63
+ * Re-fetch the existing cluster.
64
+ */
65
+ const reFetchedCluster: Model | null = await this.findOneBy({
66
+ query: {
67
+ projectId: data.projectId,
68
+ clusterIdentifier: data.clusterIdentifier,
69
+ },
70
+ select: {
71
+ _id: true,
72
+ projectId: true,
73
+ clusterIdentifier: true,
74
+ },
75
+ props: {
76
+ isRoot: true,
77
+ },
78
+ });
79
+
80
+ if (reFetchedCluster) {
81
+ return reFetchedCluster;
82
+ }
53
83
 
54
- return createdCluster;
84
+ throw new Error(
85
+ "Failed to create or find cluster: " + data.clusterIdentifier,
86
+ );
87
+ }
55
88
  }
56
89
 
57
90
  @CaptureSpan()
58
91
  public async updateLastSeen(clusterId: ObjectID): Promise<void> {
92
+ const cacheKey: string = clusterId.toString();
93
+
94
+ const cached: string | null = await GlobalCache.getString(
95
+ LAST_SEEN_CACHE_NAMESPACE,
96
+ cacheKey,
97
+ );
98
+
99
+ if (cached) {
100
+ return; // another pod already updated recently
101
+ }
102
+
103
+ await GlobalCache.setString(LAST_SEEN_CACHE_NAMESPACE, cacheKey, "1", {
104
+ expiresInSeconds: LAST_SEEN_THROTTLE_SECONDS,
105
+ });
106
+
59
107
  await this.updateOneById({
60
108
  id: clusterId,
61
109
  data: {
@@ -3,6 +3,7 @@ import { OnCreate } from "../Types/Database/Hooks";
3
3
  import QueryHelper from "../Types/Database/QueryHelper";
4
4
  import DatabaseService from "./DatabaseService";
5
5
  import BadDataException from "../../Types/Exception/BadDataException";
6
+ import ObjectID from "../../Types/ObjectID";
6
7
  import Model from "../../Models/DatabaseModels/Label";
7
8
  import CaptureSpan from "../Utils/Telemetry/CaptureSpan";
8
9
  export class Service extends DatabaseService<Model> {
@@ -14,13 +15,25 @@ export class Service extends DatabaseService<Model> {
14
15
  protected override async onBeforeCreate(
15
16
  createBy: CreateBy<Model>,
16
17
  ): Promise<OnCreate<Model>> {
18
+ let projectId: ObjectID | undefined = createBy.props.tenantId;
19
+
20
+ if (createBy.props.isMasterAdmin || createBy.props.isRoot) {
21
+ if (createBy.data.projectId) {
22
+ projectId = createBy.data.projectId;
23
+ }
24
+ }
25
+
26
+ if (!projectId) {
27
+ throw new BadDataException("Project ID is required to create a label.");
28
+ }
29
+
17
30
  let existingProjectWithSameNameCount: number = 0;
18
31
 
19
32
  existingProjectWithSameNameCount = (
20
33
  await this.countBy({
21
34
  query: {
22
35
  name: QueryHelper.findWithSameText(createBy.data.name!),
23
- projectId: createBy.props.tenantId!,
36
+ projectId: projectId,
24
37
  },
25
38
  props: {
26
39
  isRoot: true,
@@ -4,7 +4,7 @@ import OneUptimeDate from "../../Types/Date";
4
4
  import BadDataException from "../../Types/Exception/BadDataException";
5
5
  import ObjectID from "../../Types/ObjectID";
6
6
  import { IsBillingEnabled } from "../EnvironmentConfig";
7
- import logger from "../Utils/Logger";
7
+ import logger, { LogAttributes } from "../Utils/Logger";
8
8
  import DatabaseService from "./DatabaseService";
9
9
  import MonitorFeed, {
10
10
  MonitorFeedEventType,
@@ -43,8 +43,14 @@ export class Service extends DatabaseService<MonitorFeed> {
43
43
  | undefined;
44
44
  }): Promise<void> {
45
45
  try {
46
- logger.debug("MonitorFeedService.createMonitorFeedItem");
47
- logger.debug(data);
46
+ logger.debug("MonitorFeedService.createMonitorFeedItem", {
47
+ projectId: data.projectId?.toString(),
48
+ monitorId: data.monitorId?.toString(),
49
+ } as LogAttributes);
50
+ logger.debug(data, {
51
+ projectId: data.projectId?.toString(),
52
+ monitorId: data.monitorId?.toString(),
53
+ } as LogAttributes);
48
54
 
49
55
  const monitorFeed: MonitorFeed = new MonitorFeed();
50
56
 
@@ -93,8 +99,14 @@ export class Service extends DatabaseService<MonitorFeed> {
93
99
  },
94
100
  });
95
101
 
96
- logger.debug("Monitor Feed created");
97
- logger.debug(createdMonitorFeed);
102
+ logger.debug("Monitor Feed created", {
103
+ projectId: data.projectId?.toString(),
104
+ monitorId: data.monitorId?.toString(),
105
+ } as LogAttributes);
106
+ logger.debug(createdMonitorFeed, {
107
+ projectId: data.projectId?.toString(),
108
+ monitorId: data.monitorId?.toString(),
109
+ } as LogAttributes);
98
110
 
99
111
  try {
100
112
  // send notification to slack and teams
@@ -110,14 +122,26 @@ export class Service extends DatabaseService<MonitorFeed> {
110
122
  });
111
123
  }
112
124
  } catch (e) {
113
- logger.error("Error in sending notification to slack and teams");
114
- logger.error(e);
125
+ logger.error("Error in sending notification to slack and teams", {
126
+ projectId: data.projectId?.toString(),
127
+ monitorId: data.monitorId?.toString(),
128
+ } as LogAttributes);
129
+ logger.error(e, {
130
+ projectId: data.projectId?.toString(),
131
+ monitorId: data.monitorId?.toString(),
132
+ } as LogAttributes);
115
133
 
116
134
  // we dont throw this error as it is not a critical error
117
135
  }
118
136
  } catch (e) {
119
- logger.error("Error in creating monitor feed");
120
- logger.error(e);
137
+ logger.error("Error in creating monitor feed", {
138
+ projectId: data.projectId?.toString(),
139
+ monitorId: data.monitorId?.toString(),
140
+ } as LogAttributes);
141
+ logger.error(e, {
142
+ projectId: data.projectId?.toString(),
143
+ monitorId: data.monitorId?.toString(),
144
+ } as LogAttributes);
121
145
 
122
146
  // we dont throw this error as it is not a critical error
123
147
  }
@@ -5,11 +5,13 @@ import DatabaseService, { EntityManager } from "./DatabaseService";
5
5
  import OneUptimeDate from "../../Types/Date";
6
6
  import BadDataException from "../../Types/Exception/BadDataException";
7
7
  import MonitorProbe from "../../Models/DatabaseModels/MonitorProbe";
8
+ import Monitor from "../../Models/DatabaseModels/Monitor";
8
9
  import QueryHelper from "../Types/Database/QueryHelper";
9
10
  import { LIMIT_PER_PROJECT } from "../../Types/Database/LimitMax";
10
11
  import MonitorService from "./MonitorService";
12
+ import { MonitorTypeHelper } from "../../Types/Monitor/MonitorType";
11
13
  import CronTab from "../Utils/CronTab";
12
- import logger from "../Utils/Logger";
14
+ import logger, { LogAttributes } from "../Utils/Logger";
13
15
 
14
16
  export class Service extends DatabaseService<MonitorProbe> {
15
17
  public constructor() {
@@ -52,7 +54,9 @@ export class Service extends DatabaseService<MonitorProbe> {
52
54
  monitorProbe?.monitor?.monitoringInterval as string,
53
55
  );
54
56
  } catch (err) {
55
- logger.error(err);
57
+ logger.error(err, {
58
+ monitorId: data.monitorId?.toString(),
59
+ } as LogAttributes);
56
60
  }
57
61
 
58
62
  if (nextPing && monitorProbe.id) {
@@ -189,6 +193,31 @@ export class Service extends DatabaseService<MonitorProbe> {
189
193
  }
190
194
  }
191
195
 
196
+ // Check if the monitor type supports probes
197
+ const monitorId: ObjectID | undefined | null =
198
+ createBy.data.monitorId || createBy.data.monitor?.id;
199
+
200
+ if (monitorId) {
201
+ const monitor: Monitor | null = await MonitorService.findOneById({
202
+ id: monitorId,
203
+ select: {
204
+ monitorType: true,
205
+ },
206
+ props: {
207
+ isRoot: true,
208
+ },
209
+ });
210
+
211
+ if (
212
+ monitor?.monitorType &&
213
+ !MonitorTypeHelper.isProbableMonitor(monitor.monitorType)
214
+ ) {
215
+ throw new BadDataException(
216
+ "Probes cannot be added to this monitor type.",
217
+ );
218
+ }
219
+ }
220
+
192
221
  if (!createBy.data.nextPingAt) {
193
222
  createBy.data.nextPingAt = OneUptimeDate.getCurrentDate();
194
223
  }
@@ -65,7 +65,7 @@ import MonitorFeedService from "./MonitorFeedService";
65
65
  import { MonitorFeedEventType } from "../../Models/DatabaseModels/MonitorFeed";
66
66
  import { Gray500, Green500 } from "../../Types/BrandColors";
67
67
  import LabelService from "./LabelService";
68
- import logger from "../Utils/Logger";
68
+ import logger, { LogAttributes } from "../Utils/Logger";
69
69
  import PushNotificationUtil from "../Utils/PushNotificationUtil";
70
70
  import ExceptionMessages from "../../Types/Exception/ExceptionMessages";
71
71
  import Project from "../../Models/DatabaseModels/Project";
@@ -263,6 +263,10 @@ export class Service extends DatabaseService<Model> {
263
263
  } catch (error) {
264
264
  logger.error(
265
265
  `Error while archiving workspace channels for monitor ${monitor.id?.toString()}: ${error}`,
266
+ {
267
+ projectId: monitor.projectId?.toString(),
268
+ monitorId: monitor.id?.toString(),
269
+ } as LogAttributes,
266
270
  );
267
271
  }
268
272
  }
@@ -620,6 +624,10 @@ ${createdItem.description?.trim() || "No description provided."}
620
624
  } catch (error) {
621
625
  logger.error(
622
626
  "Workspace operations failed in MonitorService.onCreateSuccess",
627
+ {
628
+ projectId: createdItem.projectId?.toString(),
629
+ monitorId: createdItem.id?.toString(),
630
+ } as LogAttributes,
623
631
  );
624
632
  logger.error(error as Error);
625
633
  return Promise.resolve();
@@ -639,6 +647,10 @@ ${createdItem.description?.trim() || "No description provided."}
639
647
  } catch (error) {
640
648
  logger.error(
641
649
  "Change monitor status failed in MonitorService.onCreateSuccess",
650
+ {
651
+ projectId: createdItem.projectId?.toString(),
652
+ monitorId: createdItem.id?.toString(),
653
+ } as LogAttributes,
642
654
  );
643
655
  logger.error(error as Error);
644
656
  return Promise.resolve();
@@ -659,6 +671,10 @@ ${createdItem.description?.trim() || "No description provided."}
659
671
  } catch (error) {
660
672
  logger.error(
661
673
  "Add default probes failed in MonitorService.onCreateSuccess",
674
+ {
675
+ projectId: createdItem.projectId?.toString(),
676
+ monitorId: createdItem.id?.toString(),
677
+ } as LogAttributes,
662
678
  );
663
679
  logger.error(error as Error);
664
680
  return Promise.resolve();
@@ -675,6 +691,10 @@ ${createdItem.description?.trim() || "No description provided."}
675
691
  } catch (error) {
676
692
  logger.error(
677
693
  "Billing operations failed in MonitorService.onCreateSuccess",
694
+ {
695
+ projectId: createdItem.projectId?.toString(),
696
+ monitorId: createdItem.id?.toString(),
697
+ } as LogAttributes,
678
698
  );
679
699
  logger.error(error as Error);
680
700
  return Promise.resolve();
@@ -702,7 +722,10 @@ ${createdItem.description?.trim() || "No description provided."}
702
722
  }
703
723
  return Promise.resolve();
704
724
  } catch (error) {
705
- logger.error("Add owners failed in MonitorService.onCreateSuccess");
725
+ logger.error("Add owners failed in MonitorService.onCreateSuccess", {
726
+ projectId: createdItem.projectId?.toString(),
727
+ monitorId: createdItem.id?.toString(),
728
+ } as LogAttributes);
706
729
  logger.error(error as Error);
707
730
  return Promise.resolve();
708
731
  }
@@ -713,6 +736,10 @@ ${createdItem.description?.trim() || "No description provided."}
713
736
  } catch (error) {
714
737
  logger.error(
715
738
  "Refresh probe status failed in MonitorService.onCreateSuccess",
739
+ {
740
+ projectId: createdItem.projectId?.toString(),
741
+ monitorId: createdItem.id?.toString(),
742
+ } as LogAttributes,
716
743
  );
717
744
  logger.error(error as Error);
718
745
  return Promise.resolve();
@@ -721,6 +748,10 @@ ${createdItem.description?.trim() || "No description provided."}
721
748
  .catch((error: Error) => {
722
749
  logger.error(
723
750
  `Critical error in MonitorService sequential operations: ${error}`,
751
+ {
752
+ projectId: createdItem.projectId?.toString(),
753
+ monitorId: createdItem.id?.toString(),
754
+ } as LogAttributes,
724
755
  );
725
756
  });
726
757
 
@@ -1287,7 +1318,7 @@ ${createdItem.description?.trim() || "No description provided."}
1287
1318
  const emailMessage: EmailEnvelope = {
1288
1319
  templateType: EmailTemplateType.MonitorProbesStatus,
1289
1320
  vars: vars,
1290
- subject: `[Monitor Probes ${enabledStatus}] ${monitor.name!}`,
1321
+ subject: `[${enabledStatus} Monitor Probes] ${monitor.name!}`,
1291
1322
  };
1292
1323
 
1293
1324
  const sms: SMSMessage = {
@@ -1417,7 +1448,7 @@ ${createdItem.description?.trim() || "No description provided."}
1417
1448
  const emailMessage: EmailEnvelope = {
1418
1449
  templateType: EmailTemplateType.MonitorProbesStatus,
1419
1450
  vars: vars,
1420
- subject: `[Monitor Probes ${status}] ${monitor.name!}`,
1451
+ subject: `[${status} Monitor Probes] ${monitor.name!}`,
1421
1452
  };
1422
1453
 
1423
1454
  const sms: SMSMessage = {