@oneuptime/common 9.4.12 → 9.4.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Models/DatabaseModels/Incident.ts +77 -0
- package/Models/DatabaseModels/IncidentEpisode.ts +1223 -0
- package/Models/DatabaseModels/IncidentEpisodeFeed.ts +533 -0
- package/Models/DatabaseModels/IncidentEpisodeInternalNote.ts +456 -0
- package/Models/DatabaseModels/IncidentEpisodeMember.ts +587 -0
- package/Models/DatabaseModels/IncidentEpisodeOwnerTeam.ts +421 -0
- package/Models/DatabaseModels/IncidentEpisodeOwnerUser.ts +419 -0
- package/Models/DatabaseModels/IncidentEpisodeStateTimeline.ts +524 -0
- package/Models/DatabaseModels/IncidentGroupingRule.ts +1430 -0
- package/Models/DatabaseModels/Index.ts +18 -0
- package/Models/DatabaseModels/OnCallDutyPolicyExecutionLog.ts +70 -0
- package/Models/DatabaseModels/OnCallDutyPolicyExecutionLogTimeline.ts +59 -0
- package/Models/DatabaseModels/UserOnCallLog.ts +48 -0
- package/Models/DatabaseModels/UserOnCallLogTimeline.ts +49 -0
- package/Models/DatabaseModels/WorkspaceNotificationLog.ts +57 -0
- package/Server/API/IncidentEpisodeAPI.ts +150 -0
- package/Server/API/SlackAPI.ts +23 -0
- package/Server/API/UserOnCallLogTimelineAPI.ts +24 -4
- package/Server/Infrastructure/Postgres/SchemaMigrations/1769626069479-MigrationName.ts +729 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1769629928240-MigrationName.ts +261 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1769676117342-RenameEvaluateOverTimeInCriteriaFilter.ts +28 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +6 -0
- package/Server/Services/BillingService.ts +1 -3
- package/Server/Services/CallService.ts +1 -0
- package/Server/Services/IncidentEpisodeFeedService.ts +94 -0
- package/Server/Services/IncidentEpisodeInternalNoteService.ts +71 -0
- package/Server/Services/IncidentEpisodeMemberService.ts +321 -0
- package/Server/Services/IncidentEpisodeOwnerTeamService.ts +10 -0
- package/Server/Services/IncidentEpisodeOwnerUserService.ts +10 -0
- package/Server/Services/IncidentEpisodeService.ts +1045 -0
- package/Server/Services/IncidentEpisodeStateTimelineService.ts +566 -0
- package/Server/Services/IncidentGroupingEngineService.ts +1047 -0
- package/Server/Services/IncidentGroupingRuleService.ts +14 -0
- package/Server/Services/IncidentService.ts +11 -0
- package/Server/Services/Index.ts +18 -0
- package/Server/Services/MailService.ts +1 -0
- package/Server/Services/MonitorService.ts +9 -0
- package/Server/Services/OnCallDutyPolicyEscalationRuleService.ts +18 -0
- package/Server/Services/OnCallDutyPolicyExecutionLogService.ts +64 -2
- package/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.ts +26 -1
- package/Server/Services/OnCallDutyPolicyService.ts +15 -0
- package/Server/Services/SmsService.ts +1 -0
- package/Server/Services/UserNotificationRuleService.ts +48 -2
- package/Server/Services/UserNotificationSettingService.ts +23 -0
- package/Server/Services/UserOnCallLogService.ts +41 -4
- package/Server/Services/WhatsAppService.ts +1 -0
- package/Server/Services/WorkspaceNotificationLogService.ts +16 -0
- package/Server/Services/WorkspaceNotificationRuleService.ts +116 -0
- package/Server/Utils/AI/IncidentEpisodeAIContextBuilder.ts +490 -0
- package/Server/Utils/Monitor/Criteria/APIRequestCriteria.ts +1 -1
- package/Server/Utils/Monitor/Criteria/CompareCriteria.ts +1 -1
- package/Server/Utils/Monitor/Criteria/IncomingRequestCriteria.ts +1 -1
- package/Server/Utils/Monitor/Criteria/SSLMonitorCriteria.ts +1 -1
- package/Server/Utils/Monitor/Criteria/ServerMonitorCriteria.ts +2 -2
- package/Server/Utils/Monitor/Criteria/SnmpMonitorCriteria.ts +182 -0
- package/Server/Utils/Monitor/MonitorCriteriaEvaluator.ts +13 -0
- package/Server/Utils/Monitor/MonitorCriteriaExpectationBuilder.ts +1 -1
- package/Server/Utils/Monitor/MonitorTemplateUtil.ts +37 -0
- package/Server/Utils/PushNotificationUtil.ts +31 -0
- package/Server/Utils/WhatsAppTemplateUtil.ts +14 -0
- package/Server/Utils/Workspace/MicrosoftTeams/Actions/ActionTypes.ts +18 -0
- package/Server/Utils/Workspace/MicrosoftTeams/Actions/IncidentEpisode.ts +702 -0
- package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.ts +20 -0
- package/Server/Utils/Workspace/Slack/Actions/ActionTypes.ts +11 -0
- package/Server/Utils/Workspace/Slack/Actions/IncidentEpisode.ts +918 -0
- package/Server/Utils/Workspace/Slack/Messages/IncidentEpisode.ts +120 -0
- package/Server/Utils/Workspace/WorkspaceMessages/IncidentEpisode.ts +74 -0
- package/Types/Email/EmailTemplateType.ts +6 -0
- package/Types/Monitor/CriteriaFilter.ts +24 -4
- package/Types/Monitor/MonitorCriteriaInstance.ts +67 -0
- package/Types/Monitor/MonitorStep.ts +37 -0
- package/Types/Monitor/MonitorStepSnmpMonitor.ts +102 -0
- package/Types/Monitor/MonitorType.ts +15 -2
- package/Types/Monitor/SnmpMonitor/SnmpAuthProtocol.ts +8 -0
- package/Types/Monitor/SnmpMonitor/SnmpDataType.ts +21 -0
- package/Types/Monitor/SnmpMonitor/SnmpMonitorResponse.ts +16 -0
- package/Types/Monitor/SnmpMonitor/SnmpOid.ts +60 -0
- package/Types/Monitor/SnmpMonitor/SnmpPrivProtocol.ts +7 -0
- package/Types/Monitor/SnmpMonitor/SnmpSecurityLevel.ts +7 -0
- package/Types/Monitor/SnmpMonitor/SnmpV3Auth.ts +12 -0
- package/Types/Monitor/SnmpMonitor/SnmpVersion.ts +7 -0
- package/Types/NotificationSetting/NotificationSettingEventType.ts +7 -0
- package/Types/Permission.ts +311 -0
- package/Types/Probe/ProbeMonitorResponse.ts +2 -0
- package/Types/UserNotification/UserNotificationEventType.ts +1 -0
- package/Types/WhatsApp/WhatsAppTemplates.ts +24 -0
- package/Types/Workspace/NotificationRules/EventType.ts +1 -0
- package/Types/Workspace/NotificationRules/NotificationRuleCondition.ts +38 -1
- package/Utils/Monitor/MonitorMetricType.ts +2 -1
- package/build/dist/Models/DatabaseModels/Incident.js +78 -0
- package/build/dist/Models/DatabaseModels/Incident.js.map +1 -1
- package/build/dist/Models/DatabaseModels/IncidentEpisode.js +1250 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisode.js.map +1 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeFeed.js +555 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeFeed.js.map +1 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeInternalNote.js +467 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeInternalNote.js.map +1 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeMember.js +607 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeMember.js.map +1 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeOwnerTeam.js +437 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeOwnerTeam.js.map +1 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeOwnerUser.js +436 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeOwnerUser.js.map +1 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeStateTimeline.js +546 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeStateTimeline.js.map +1 -0
- package/build/dist/Models/DatabaseModels/IncidentGroupingRule.js +1437 -0
- package/build/dist/Models/DatabaseModels/IncidentGroupingRule.js.map +1 -0
- package/build/dist/Models/DatabaseModels/Index.js +16 -0
- package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyExecutionLog.js +69 -0
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyExecutionLog.js.map +1 -1
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyExecutionLogTimeline.js +58 -0
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyExecutionLogTimeline.js.map +1 -1
- package/build/dist/Models/DatabaseModels/UserOnCallLog.js +47 -0
- package/build/dist/Models/DatabaseModels/UserOnCallLog.js.map +1 -1
- package/build/dist/Models/DatabaseModels/UserOnCallLogTimeline.js +48 -0
- package/build/dist/Models/DatabaseModels/UserOnCallLogTimeline.js.map +1 -1
- package/build/dist/Models/DatabaseModels/WorkspaceNotificationLog.js +58 -0
- package/build/dist/Models/DatabaseModels/WorkspaceNotificationLog.js.map +1 -1
- package/build/dist/Server/API/IncidentEpisodeAPI.js +97 -0
- package/build/dist/Server/API/IncidentEpisodeAPI.js.map +1 -0
- package/build/dist/Server/API/SlackAPI.js +18 -0
- package/build/dist/Server/API/SlackAPI.js.map +1 -1
- package/build/dist/Server/API/UserOnCallLogTimelineAPI.js +30 -10
- package/build/dist/Server/API/UserOnCallLogTimelineAPI.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769626069479-MigrationName.js +256 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769626069479-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769629928240-MigrationName.js +96 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769629928240-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769676117342-RenameEvaluateOverTimeInCriteriaFilter.js +25 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769676117342-RenameEvaluateOverTimeInCriteriaFilter.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +6 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Services/BillingService.js +1 -2
- package/build/dist/Server/Services/BillingService.js.map +1 -1
- package/build/dist/Server/Services/CallService.js.map +1 -1
- package/build/dist/Server/Services/IncidentEpisodeFeedService.js +83 -0
- package/build/dist/Server/Services/IncidentEpisodeFeedService.js.map +1 -0
- package/build/dist/Server/Services/IncidentEpisodeInternalNoteService.js +70 -0
- package/build/dist/Server/Services/IncidentEpisodeInternalNoteService.js.map +1 -0
- package/build/dist/Server/Services/IncidentEpisodeMemberService.js +298 -0
- package/build/dist/Server/Services/IncidentEpisodeMemberService.js.map +1 -0
- package/build/dist/Server/Services/IncidentEpisodeOwnerTeamService.js +9 -0
- package/build/dist/Server/Services/IncidentEpisodeOwnerTeamService.js.map +1 -0
- package/build/dist/Server/Services/IncidentEpisodeOwnerUserService.js +9 -0
- package/build/dist/Server/Services/IncidentEpisodeOwnerUserService.js.map +1 -0
- package/build/dist/Server/Services/IncidentEpisodeService.js +933 -0
- package/build/dist/Server/Services/IncidentEpisodeService.js.map +1 -0
- package/build/dist/Server/Services/IncidentEpisodeStateTimelineService.js +498 -0
- package/build/dist/Server/Services/IncidentEpisodeStateTimelineService.js.map +1 -0
- package/build/dist/Server/Services/IncidentGroupingEngineService.js +799 -0
- package/build/dist/Server/Services/IncidentGroupingEngineService.js.map +1 -0
- package/build/dist/Server/Services/IncidentGroupingRuleService.js +13 -0
- package/build/dist/Server/Services/IncidentGroupingRuleService.js.map +1 -0
- package/build/dist/Server/Services/IncidentService.js +10 -0
- package/build/dist/Server/Services/IncidentService.js.map +1 -1
- package/build/dist/Server/Services/Index.js +16 -0
- package/build/dist/Server/Services/Index.js.map +1 -1
- package/build/dist/Server/Services/MailService.js.map +1 -1
- package/build/dist/Server/Services/MonitorService.js +9 -1
- package/build/dist/Server/Services/MonitorService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleService.js +10 -0
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogService.js +48 -2
- package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.js +20 -1
- package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyService.js +8 -0
- package/build/dist/Server/Services/OnCallDutyPolicyService.js.map +1 -1
- package/build/dist/Server/Services/SmsService.js.map +1 -1
- package/build/dist/Server/Services/UserNotificationRuleService.js +39 -2
- package/build/dist/Server/Services/UserNotificationRuleService.js.map +1 -1
- package/build/dist/Server/Services/UserNotificationSettingService.js +9 -0
- package/build/dist/Server/Services/UserNotificationSettingService.js.map +1 -1
- package/build/dist/Server/Services/UserOnCallLogService.js +35 -3
- package/build/dist/Server/Services/UserOnCallLogService.js.map +1 -1
- package/build/dist/Server/Services/WhatsAppService.js.map +1 -1
- package/build/dist/Server/Services/WorkspaceNotificationLogService.js +12 -0
- package/build/dist/Server/Services/WorkspaceNotificationLogService.js.map +1 -1
- package/build/dist/Server/Services/WorkspaceNotificationRuleService.js +95 -1
- package/build/dist/Server/Services/WorkspaceNotificationRuleService.js.map +1 -1
- package/build/dist/Server/Utils/AI/IncidentEpisodeAIContextBuilder.js +402 -0
- package/build/dist/Server/Utils/AI/IncidentEpisodeAIContextBuilder.js.map +1 -0
- package/build/dist/Server/Utils/Monitor/Criteria/APIRequestCriteria.js +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/CompareCriteria.js +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/IncomingRequestCriteria.js +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/SSLMonitorCriteria.js +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/ServerMonitorCriteria.js +2 -2
- package/build/dist/Server/Utils/Monitor/Criteria/SnmpMonitorCriteria.js +135 -0
- package/build/dist/Server/Utils/Monitor/Criteria/SnmpMonitorCriteria.js.map +1 -0
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js +10 -0
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaExpectationBuilder.js +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorTemplateUtil.js +26 -0
- package/build/dist/Server/Utils/Monitor/MonitorTemplateUtil.js.map +1 -1
- package/build/dist/Server/Utils/PushNotificationUtil.js +20 -0
- package/build/dist/Server/Utils/PushNotificationUtil.js.map +1 -1
- package/build/dist/Server/Utils/WhatsAppTemplateUtil.js +8 -0
- package/build/dist/Server/Utils/WhatsAppTemplateUtil.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/ActionTypes.js +17 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/ActionTypes.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/IncidentEpisode.js +547 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/IncidentEpisode.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js +15 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/Slack/Actions/ActionTypes.js +10 -0
- package/build/dist/Server/Utils/Workspace/Slack/Actions/ActionTypes.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/Slack/Actions/IncidentEpisode.js +651 -0
- package/build/dist/Server/Utils/Workspace/Slack/Actions/IncidentEpisode.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/Slack/Messages/IncidentEpisode.js +100 -0
- package/build/dist/Server/Utils/Workspace/Slack/Messages/IncidentEpisode.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/WorkspaceMessages/IncidentEpisode.js +70 -0
- package/build/dist/Server/Utils/Workspace/WorkspaceMessages/IncidentEpisode.js.map +1 -0
- package/build/dist/Types/Email/EmailTemplateType.js +5 -0
- package/build/dist/Types/Email/EmailTemplateType.js.map +1 -1
- package/build/dist/Types/Monitor/CriteriaFilter.js +16 -3
- package/build/dist/Types/Monitor/CriteriaFilter.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorCriteriaInstance.js +62 -0
- package/build/dist/Types/Monitor/MonitorCriteriaInstance.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorStep.js +26 -0
- package/build/dist/Types/Monitor/MonitorStep.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorStepSnmpMonitor.js +77 -0
- package/build/dist/Types/Monitor/MonitorStepSnmpMonitor.js.map +1 -0
- package/build/dist/Types/Monitor/MonitorType.js +13 -2
- package/build/dist/Types/Monitor/MonitorType.js.map +1 -1
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpAuthProtocol.js +9 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpAuthProtocol.js.map +1 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpDataType.js +22 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpDataType.js.map +1 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpMonitorResponse.js +2 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpMonitorResponse.js.map +1 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpOid.js +55 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpOid.js.map +1 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpPrivProtocol.js +8 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpPrivProtocol.js.map +1 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpSecurityLevel.js +8 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpSecurityLevel.js.map +1 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpV3Auth.js +2 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpV3Auth.js.map +1 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpVersion.js +8 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpVersion.js.map +1 -0
- package/build/dist/Types/NotificationSetting/NotificationSettingEventType.js +5 -0
- package/build/dist/Types/NotificationSetting/NotificationSettingEventType.js.map +1 -1
- package/build/dist/Types/Permission.js +264 -0
- package/build/dist/Types/Permission.js.map +1 -1
- package/build/dist/Types/UserNotification/UserNotificationEventType.js +1 -0
- package/build/dist/Types/UserNotification/UserNotificationEventType.js.map +1 -1
- package/build/dist/Types/WhatsApp/WhatsAppTemplates.js +15 -0
- package/build/dist/Types/WhatsApp/WhatsAppTemplates.js.map +1 -1
- package/build/dist/Types/Workspace/NotificationRules/EventType.js +1 -0
- package/build/dist/Types/Workspace/NotificationRules/EventType.js.map +1 -1
- package/build/dist/Types/Workspace/NotificationRules/NotificationRuleCondition.js +33 -1
- package/build/dist/Types/Workspace/NotificationRules/NotificationRuleCondition.js.map +1 -1
- package/build/dist/Utils/Monitor/MonitorMetricType.js +2 -1
- package/build/dist/Utils/Monitor/MonitorMetricType.js.map +1 -1
- package/package.json +1 -1
|
@@ -21,6 +21,8 @@ export interface WorkspaceLogData {
|
|
|
21
21
|
// Relations to resources (optional)
|
|
22
22
|
incidentId?: ObjectID | undefined;
|
|
23
23
|
alertId?: ObjectID | undefined;
|
|
24
|
+
alertEpisodeId?: ObjectID | undefined;
|
|
25
|
+
incidentEpisodeId?: ObjectID | undefined;
|
|
24
26
|
scheduledMaintenanceId?: ObjectID | undefined;
|
|
25
27
|
userId?: ObjectID | undefined;
|
|
26
28
|
teamId?: ObjectID | undefined;
|
|
@@ -75,6 +77,12 @@ export class Service extends DatabaseService<Model> {
|
|
|
75
77
|
if (data.alertId) {
|
|
76
78
|
log.alertId = data.alertId;
|
|
77
79
|
}
|
|
80
|
+
if (data.alertEpisodeId) {
|
|
81
|
+
log.alertEpisodeId = data.alertEpisodeId;
|
|
82
|
+
}
|
|
83
|
+
if (data.incidentEpisodeId) {
|
|
84
|
+
log.incidentEpisodeId = data.incidentEpisodeId;
|
|
85
|
+
}
|
|
78
86
|
if (data.scheduledMaintenanceId) {
|
|
79
87
|
log.scheduledMaintenanceId = data.scheduledMaintenanceId;
|
|
80
88
|
}
|
|
@@ -221,6 +229,8 @@ export class Service extends DatabaseService<Model> {
|
|
|
221
229
|
// Optional resource associations
|
|
222
230
|
incidentId?: ObjectID;
|
|
223
231
|
alertId?: ObjectID;
|
|
232
|
+
alertEpisodeId?: ObjectID;
|
|
233
|
+
incidentEpisodeId?: ObjectID;
|
|
224
234
|
scheduledMaintenanceId?: ObjectID;
|
|
225
235
|
onCallDutyPolicyId?: ObjectID;
|
|
226
236
|
statusPageId?: ObjectID;
|
|
@@ -256,6 +266,12 @@ export class Service extends DatabaseService<Model> {
|
|
|
256
266
|
if (data.alertId) {
|
|
257
267
|
logData.alertId = data.alertId;
|
|
258
268
|
}
|
|
269
|
+
if (data.alertEpisodeId) {
|
|
270
|
+
logData.alertEpisodeId = data.alertEpisodeId;
|
|
271
|
+
}
|
|
272
|
+
if (data.incidentEpisodeId) {
|
|
273
|
+
logData.incidentEpisodeId = data.incidentEpisodeId;
|
|
274
|
+
}
|
|
259
275
|
if (data.scheduledMaintenanceId) {
|
|
260
276
|
logData.scheduledMaintenanceId = data.scheduledMaintenanceId;
|
|
261
277
|
}
|
|
@@ -50,6 +50,8 @@ import WorkspaceNotificationLogService from "./WorkspaceNotificationLogService";
|
|
|
50
50
|
import WorkspaceNotificationStatus from "../../Types/Workspace/WorkspaceNotificationStatus";
|
|
51
51
|
import WorkspaceNotificationActionType from "../../Types/Workspace/WorkspaceNotificationActionType";
|
|
52
52
|
import ExceptionMessages from "../../Types/Exception/ExceptionMessages";
|
|
53
|
+
import IncidentEpisode from "../../Models/DatabaseModels/IncidentEpisode";
|
|
54
|
+
import IncidentEpisodeService from "./IncidentEpisodeService";
|
|
53
55
|
|
|
54
56
|
export interface MessageBlocksByWorkspaceType {
|
|
55
57
|
workspaceType: WorkspaceType;
|
|
@@ -60,6 +62,7 @@ export interface NotificationFor {
|
|
|
60
62
|
incidentId?: ObjectID | undefined;
|
|
61
63
|
alertId?: ObjectID | undefined;
|
|
62
64
|
alertEpisodeId?: ObjectID | undefined;
|
|
65
|
+
incidentEpisodeId?: ObjectID | undefined;
|
|
63
66
|
scheduledMaintenanceId?: ObjectID | undefined;
|
|
64
67
|
monitorId?: ObjectID | undefined;
|
|
65
68
|
onCallDutyPolicyId?: ObjectID | undefined;
|
|
@@ -749,6 +752,14 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
|
|
749
752
|
return NotificationRuleEventType.Incident;
|
|
750
753
|
}
|
|
751
754
|
|
|
755
|
+
if (notificationFor.alertEpisodeId) {
|
|
756
|
+
return NotificationRuleEventType.AlertEpisode;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
if (notificationFor.incidentEpisodeId) {
|
|
760
|
+
return NotificationRuleEventType.IncidentEpisode;
|
|
761
|
+
}
|
|
762
|
+
|
|
752
763
|
if (notificationFor.monitorId) {
|
|
753
764
|
return NotificationRuleEventType.Monitor;
|
|
754
765
|
}
|
|
@@ -1949,6 +1960,12 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
|
|
1949
1960
|
[NotificationRuleConditionCheckOn.AlertEpisodeSeverity]: undefined,
|
|
1950
1961
|
[NotificationRuleConditionCheckOn.AlertEpisodeState]: undefined,
|
|
1951
1962
|
[NotificationRuleConditionCheckOn.AlertEpisodeLabels]: undefined,
|
|
1963
|
+
[NotificationRuleConditionCheckOn.IncidentEpisodeTitle]: undefined,
|
|
1964
|
+
[NotificationRuleConditionCheckOn.IncidentEpisodeDescription]:
|
|
1965
|
+
undefined,
|
|
1966
|
+
[NotificationRuleConditionCheckOn.IncidentEpisodeSeverity]: undefined,
|
|
1967
|
+
[NotificationRuleConditionCheckOn.IncidentEpisodeState]: undefined,
|
|
1968
|
+
[NotificationRuleConditionCheckOn.IncidentEpisodeLabels]: undefined,
|
|
1952
1969
|
};
|
|
1953
1970
|
}
|
|
1954
1971
|
|
|
@@ -2031,6 +2048,12 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
|
|
2031
2048
|
[NotificationRuleConditionCheckOn.AlertEpisodeSeverity]: undefined,
|
|
2032
2049
|
[NotificationRuleConditionCheckOn.AlertEpisodeState]: undefined,
|
|
2033
2050
|
[NotificationRuleConditionCheckOn.AlertEpisodeLabels]: undefined,
|
|
2051
|
+
[NotificationRuleConditionCheckOn.IncidentEpisodeTitle]: undefined,
|
|
2052
|
+
[NotificationRuleConditionCheckOn.IncidentEpisodeDescription]:
|
|
2053
|
+
undefined,
|
|
2054
|
+
[NotificationRuleConditionCheckOn.IncidentEpisodeSeverity]: undefined,
|
|
2055
|
+
[NotificationRuleConditionCheckOn.IncidentEpisodeState]: undefined,
|
|
2056
|
+
[NotificationRuleConditionCheckOn.IncidentEpisodeLabels]: undefined,
|
|
2034
2057
|
};
|
|
2035
2058
|
}
|
|
2036
2059
|
|
|
@@ -2119,6 +2142,12 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
|
|
2119
2142
|
[NotificationRuleConditionCheckOn.AlertEpisodeSeverity]: undefined,
|
|
2120
2143
|
[NotificationRuleConditionCheckOn.AlertEpisodeState]: undefined,
|
|
2121
2144
|
[NotificationRuleConditionCheckOn.AlertEpisodeLabels]: undefined,
|
|
2145
|
+
[NotificationRuleConditionCheckOn.IncidentEpisodeTitle]: undefined,
|
|
2146
|
+
[NotificationRuleConditionCheckOn.IncidentEpisodeDescription]:
|
|
2147
|
+
undefined,
|
|
2148
|
+
[NotificationRuleConditionCheckOn.IncidentEpisodeSeverity]: undefined,
|
|
2149
|
+
[NotificationRuleConditionCheckOn.IncidentEpisodeState]: undefined,
|
|
2150
|
+
[NotificationRuleConditionCheckOn.IncidentEpisodeLabels]: undefined,
|
|
2122
2151
|
};
|
|
2123
2152
|
}
|
|
2124
2153
|
|
|
@@ -2185,6 +2214,12 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
|
|
2185
2214
|
[NotificationRuleConditionCheckOn.AlertEpisodeSeverity]: undefined,
|
|
2186
2215
|
[NotificationRuleConditionCheckOn.AlertEpisodeState]: undefined,
|
|
2187
2216
|
[NotificationRuleConditionCheckOn.AlertEpisodeLabels]: undefined,
|
|
2217
|
+
[NotificationRuleConditionCheckOn.IncidentEpisodeTitle]: undefined,
|
|
2218
|
+
[NotificationRuleConditionCheckOn.IncidentEpisodeDescription]:
|
|
2219
|
+
undefined,
|
|
2220
|
+
[NotificationRuleConditionCheckOn.IncidentEpisodeSeverity]: undefined,
|
|
2221
|
+
[NotificationRuleConditionCheckOn.IncidentEpisodeState]: undefined,
|
|
2222
|
+
[NotificationRuleConditionCheckOn.IncidentEpisodeLabels]: undefined,
|
|
2188
2223
|
};
|
|
2189
2224
|
}
|
|
2190
2225
|
|
|
@@ -2250,6 +2285,87 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
|
|
2250
2285
|
[NotificationRuleConditionCheckOn.AlertEpisodeSeverity]: undefined,
|
|
2251
2286
|
[NotificationRuleConditionCheckOn.AlertEpisodeState]: undefined,
|
|
2252
2287
|
[NotificationRuleConditionCheckOn.AlertEpisodeLabels]: undefined,
|
|
2288
|
+
[NotificationRuleConditionCheckOn.IncidentEpisodeTitle]: undefined,
|
|
2289
|
+
[NotificationRuleConditionCheckOn.IncidentEpisodeDescription]:
|
|
2290
|
+
undefined,
|
|
2291
|
+
[NotificationRuleConditionCheckOn.IncidentEpisodeSeverity]: undefined,
|
|
2292
|
+
[NotificationRuleConditionCheckOn.IncidentEpisodeState]: undefined,
|
|
2293
|
+
[NotificationRuleConditionCheckOn.IncidentEpisodeLabels]: undefined,
|
|
2294
|
+
};
|
|
2295
|
+
}
|
|
2296
|
+
|
|
2297
|
+
// Handle Incident Episode
|
|
2298
|
+
if (data.notificationFor.incidentEpisodeId) {
|
|
2299
|
+
logger.debug("Fetching incident episode details for ID:");
|
|
2300
|
+
logger.debug(data.notificationFor.incidentEpisodeId);
|
|
2301
|
+
|
|
2302
|
+
const incidentEpisode: IncidentEpisode | null =
|
|
2303
|
+
await IncidentEpisodeService.findOneById({
|
|
2304
|
+
id: data.notificationFor.incidentEpisodeId,
|
|
2305
|
+
select: {
|
|
2306
|
+
title: true,
|
|
2307
|
+
description: true,
|
|
2308
|
+
incidentSeverity: true,
|
|
2309
|
+
currentIncidentState: true,
|
|
2310
|
+
labels: true,
|
|
2311
|
+
},
|
|
2312
|
+
props: {
|
|
2313
|
+
isRoot: true,
|
|
2314
|
+
},
|
|
2315
|
+
});
|
|
2316
|
+
|
|
2317
|
+
if (!incidentEpisode) {
|
|
2318
|
+
logger.debug("Incident Episode not found for ID:");
|
|
2319
|
+
logger.debug(data.notificationFor.incidentEpisodeId);
|
|
2320
|
+
throw new BadDataException("Incident Episode ID not found");
|
|
2321
|
+
}
|
|
2322
|
+
|
|
2323
|
+
logger.debug("Incident Episode details retrieved:");
|
|
2324
|
+
logger.debug(incidentEpisode);
|
|
2325
|
+
|
|
2326
|
+
return {
|
|
2327
|
+
[NotificationRuleConditionCheckOn.MonitorName]: undefined,
|
|
2328
|
+
[NotificationRuleConditionCheckOn.IncidentTitle]: undefined,
|
|
2329
|
+
[NotificationRuleConditionCheckOn.IncidentDescription]: undefined,
|
|
2330
|
+
[NotificationRuleConditionCheckOn.IncidentSeverity]: undefined,
|
|
2331
|
+
[NotificationRuleConditionCheckOn.IncidentState]: undefined,
|
|
2332
|
+
[NotificationRuleConditionCheckOn.MonitorType]: undefined,
|
|
2333
|
+
[NotificationRuleConditionCheckOn.MonitorStatus]: undefined,
|
|
2334
|
+
[NotificationRuleConditionCheckOn.AlertTitle]: undefined,
|
|
2335
|
+
[NotificationRuleConditionCheckOn.AlertDescription]: undefined,
|
|
2336
|
+
[NotificationRuleConditionCheckOn.AlertSeverity]: undefined,
|
|
2337
|
+
[NotificationRuleConditionCheckOn.AlertState]: undefined,
|
|
2338
|
+
[NotificationRuleConditionCheckOn.ScheduledMaintenanceTitle]: undefined,
|
|
2339
|
+
[NotificationRuleConditionCheckOn.ScheduledMaintenanceDescription]:
|
|
2340
|
+
undefined,
|
|
2341
|
+
[NotificationRuleConditionCheckOn.ScheduledMaintenanceState]: undefined,
|
|
2342
|
+
[NotificationRuleConditionCheckOn.IncidentLabels]: undefined,
|
|
2343
|
+
[NotificationRuleConditionCheckOn.AlertLabels]: undefined,
|
|
2344
|
+
[NotificationRuleConditionCheckOn.MonitorLabels]: undefined,
|
|
2345
|
+
[NotificationRuleConditionCheckOn.ScheduledMaintenanceLabels]:
|
|
2346
|
+
undefined,
|
|
2347
|
+
[NotificationRuleConditionCheckOn.Monitors]: undefined,
|
|
2348
|
+
[NotificationRuleConditionCheckOn.OnCallDutyPolicyName]: undefined,
|
|
2349
|
+
[NotificationRuleConditionCheckOn.OnCallDutyPolicyDescription]:
|
|
2350
|
+
undefined,
|
|
2351
|
+
[NotificationRuleConditionCheckOn.OnCallDutyPolicyLabels]: undefined,
|
|
2352
|
+
[NotificationRuleConditionCheckOn.AlertEpisodeTitle]: undefined,
|
|
2353
|
+
[NotificationRuleConditionCheckOn.AlertEpisodeDescription]: undefined,
|
|
2354
|
+
[NotificationRuleConditionCheckOn.AlertEpisodeSeverity]: undefined,
|
|
2355
|
+
[NotificationRuleConditionCheckOn.AlertEpisodeState]: undefined,
|
|
2356
|
+
[NotificationRuleConditionCheckOn.AlertEpisodeLabels]: undefined,
|
|
2357
|
+
[NotificationRuleConditionCheckOn.IncidentEpisodeTitle]:
|
|
2358
|
+
incidentEpisode.title || "",
|
|
2359
|
+
[NotificationRuleConditionCheckOn.IncidentEpisodeDescription]:
|
|
2360
|
+
incidentEpisode.description || "",
|
|
2361
|
+
[NotificationRuleConditionCheckOn.IncidentEpisodeSeverity]:
|
|
2362
|
+
incidentEpisode.incidentSeverity?._id?.toString() || "",
|
|
2363
|
+
[NotificationRuleConditionCheckOn.IncidentEpisodeState]:
|
|
2364
|
+
incidentEpisode.currentIncidentState?._id?.toString() || "",
|
|
2365
|
+
[NotificationRuleConditionCheckOn.IncidentEpisodeLabels]:
|
|
2366
|
+
incidentEpisode.labels?.map((label: Label) => {
|
|
2367
|
+
return label._id?.toString() || "";
|
|
2368
|
+
}) || [],
|
|
2253
2369
|
};
|
|
2254
2370
|
}
|
|
2255
2371
|
|
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
import ObjectID from "../../../Types/ObjectID";
|
|
2
|
+
import IncidentEpisode from "../../../Models/DatabaseModels/IncidentEpisode";
|
|
3
|
+
import IncidentEpisodeStateTimeline from "../../../Models/DatabaseModels/IncidentEpisodeStateTimeline";
|
|
4
|
+
import IncidentEpisodeInternalNote from "../../../Models/DatabaseModels/IncidentEpisodeInternalNote";
|
|
5
|
+
import IncidentEpisodeMember from "../../../Models/DatabaseModels/IncidentEpisodeMember";
|
|
6
|
+
import IncidentEpisodeService from "../../Services/IncidentEpisodeService";
|
|
7
|
+
import IncidentEpisodeStateTimelineService from "../../Services/IncidentEpisodeStateTimelineService";
|
|
8
|
+
import IncidentEpisodeInternalNoteService from "../../Services/IncidentEpisodeInternalNoteService";
|
|
9
|
+
import IncidentEpisodeMemberService from "../../Services/IncidentEpisodeMemberService";
|
|
10
|
+
import WorkspaceUtil, { WorkspaceChannelMessage } from "../Workspace/Workspace";
|
|
11
|
+
import WorkspaceProjectAuthTokenService from "../../Services/WorkspaceProjectAuthTokenService";
|
|
12
|
+
import WorkspaceProjectAuthToken from "../../../Models/DatabaseModels/WorkspaceProjectAuthToken";
|
|
13
|
+
import logger from "../Logger";
|
|
14
|
+
import CaptureSpan from "../Telemetry/CaptureSpan";
|
|
15
|
+
import OneUptimeDate from "../../../Types/Date";
|
|
16
|
+
import SortOrder from "../../../Types/BaseDatabase/SortOrder";
|
|
17
|
+
import { LLMMessage } from "../LLM/LLMService";
|
|
18
|
+
import NotificationRuleWorkspaceChannel from "../../../Types/Workspace/NotificationRules/NotificationRuleWorkspaceChannel";
|
|
19
|
+
import WorkspaceType from "../../../Types/Workspace/WorkspaceType";
|
|
20
|
+
import { AIGenerationContext } from "./IncidentAIContextBuilder";
|
|
21
|
+
import Incident from "../../../Models/DatabaseModels/Incident";
|
|
22
|
+
|
|
23
|
+
export interface IncidentEpisodeContextData {
|
|
24
|
+
episode: IncidentEpisode;
|
|
25
|
+
stateTimeline: Array<IncidentEpisodeStateTimeline>;
|
|
26
|
+
internalNotes: Array<IncidentEpisodeInternalNote>;
|
|
27
|
+
memberIncidents: Array<IncidentEpisodeMember>;
|
|
28
|
+
workspaceMessages: Array<WorkspaceChannelMessage>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default class IncidentEpisodeAIContextBuilder {
|
|
32
|
+
@CaptureSpan()
|
|
33
|
+
public static async buildEpisodeContext(data: {
|
|
34
|
+
episodeId: ObjectID;
|
|
35
|
+
includeWorkspaceMessages?: boolean;
|
|
36
|
+
workspaceMessageLimit?: number;
|
|
37
|
+
}): Promise<IncidentEpisodeContextData> {
|
|
38
|
+
const episode: IncidentEpisode | null =
|
|
39
|
+
await IncidentEpisodeService.findOneById({
|
|
40
|
+
id: data.episodeId,
|
|
41
|
+
select: {
|
|
42
|
+
_id: true,
|
|
43
|
+
title: true,
|
|
44
|
+
description: true,
|
|
45
|
+
createdAt: true,
|
|
46
|
+
postmortemNote: true,
|
|
47
|
+
remediationNotes: true,
|
|
48
|
+
rootCause: true,
|
|
49
|
+
projectId: true,
|
|
50
|
+
episodeNumber: true,
|
|
51
|
+
incidentSeverity: {
|
|
52
|
+
name: true,
|
|
53
|
+
color: true,
|
|
54
|
+
},
|
|
55
|
+
currentIncidentState: {
|
|
56
|
+
name: true,
|
|
57
|
+
color: true,
|
|
58
|
+
},
|
|
59
|
+
labels: {
|
|
60
|
+
name: true,
|
|
61
|
+
color: true,
|
|
62
|
+
},
|
|
63
|
+
postUpdatesToWorkspaceChannels: true,
|
|
64
|
+
},
|
|
65
|
+
props: {
|
|
66
|
+
isRoot: true,
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
if (!episode) {
|
|
71
|
+
throw new Error("Incident Episode not found");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Fetch state timeline
|
|
75
|
+
const stateTimeline: Array<IncidentEpisodeStateTimeline> =
|
|
76
|
+
await IncidentEpisodeStateTimelineService.findBy({
|
|
77
|
+
query: {
|
|
78
|
+
incidentEpisodeId: data.episodeId,
|
|
79
|
+
},
|
|
80
|
+
select: {
|
|
81
|
+
_id: true,
|
|
82
|
+
createdAt: true,
|
|
83
|
+
startsAt: true,
|
|
84
|
+
endsAt: true,
|
|
85
|
+
rootCause: true,
|
|
86
|
+
incidentState: {
|
|
87
|
+
name: true,
|
|
88
|
+
color: true,
|
|
89
|
+
},
|
|
90
|
+
createdByUser: {
|
|
91
|
+
name: true,
|
|
92
|
+
email: true,
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
sort: {
|
|
96
|
+
startsAt: SortOrder.Ascending,
|
|
97
|
+
},
|
|
98
|
+
limit: 100,
|
|
99
|
+
skip: 0,
|
|
100
|
+
props: {
|
|
101
|
+
isRoot: true,
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// Fetch internal notes
|
|
106
|
+
const internalNotes: Array<IncidentEpisodeInternalNote> =
|
|
107
|
+
await IncidentEpisodeInternalNoteService.findBy({
|
|
108
|
+
query: {
|
|
109
|
+
incidentEpisodeId: data.episodeId,
|
|
110
|
+
},
|
|
111
|
+
select: {
|
|
112
|
+
_id: true,
|
|
113
|
+
note: true,
|
|
114
|
+
createdAt: true,
|
|
115
|
+
createdByUser: {
|
|
116
|
+
name: true,
|
|
117
|
+
email: true,
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
sort: {
|
|
121
|
+
createdAt: SortOrder.Ascending,
|
|
122
|
+
},
|
|
123
|
+
limit: 100,
|
|
124
|
+
skip: 0,
|
|
125
|
+
props: {
|
|
126
|
+
isRoot: true,
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// Fetch member incidents
|
|
131
|
+
const memberIncidents: Array<IncidentEpisodeMember> =
|
|
132
|
+
await IncidentEpisodeMemberService.findBy({
|
|
133
|
+
query: {
|
|
134
|
+
incidentEpisodeId: data.episodeId,
|
|
135
|
+
},
|
|
136
|
+
select: {
|
|
137
|
+
_id: true,
|
|
138
|
+
createdAt: true,
|
|
139
|
+
incident: {
|
|
140
|
+
_id: true,
|
|
141
|
+
title: true,
|
|
142
|
+
description: true,
|
|
143
|
+
incidentNumber: true,
|
|
144
|
+
createdAt: true,
|
|
145
|
+
rootCause: true,
|
|
146
|
+
remediationNotes: true,
|
|
147
|
+
incidentSeverity: {
|
|
148
|
+
name: true,
|
|
149
|
+
},
|
|
150
|
+
currentIncidentState: {
|
|
151
|
+
name: true,
|
|
152
|
+
},
|
|
153
|
+
monitors: {
|
|
154
|
+
name: true,
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
sort: {
|
|
159
|
+
createdAt: SortOrder.Ascending,
|
|
160
|
+
},
|
|
161
|
+
limit: 50,
|
|
162
|
+
skip: 0,
|
|
163
|
+
props: {
|
|
164
|
+
isRoot: true,
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
// Fetch workspace messages if requested and channels exist
|
|
169
|
+
let workspaceMessages: Array<WorkspaceChannelMessage> = [];
|
|
170
|
+
|
|
171
|
+
const workspaceChannels:
|
|
172
|
+
| Array<NotificationRuleWorkspaceChannel>
|
|
173
|
+
| undefined = episode.postUpdatesToWorkspaceChannels as
|
|
174
|
+
| Array<NotificationRuleWorkspaceChannel>
|
|
175
|
+
| undefined;
|
|
176
|
+
|
|
177
|
+
if (
|
|
178
|
+
data.includeWorkspaceMessages &&
|
|
179
|
+
workspaceChannels &&
|
|
180
|
+
workspaceChannels.length > 0 &&
|
|
181
|
+
episode.projectId
|
|
182
|
+
) {
|
|
183
|
+
try {
|
|
184
|
+
const fetchParams: {
|
|
185
|
+
projectId: ObjectID;
|
|
186
|
+
workspaceChannels: Array<NotificationRuleWorkspaceChannel>;
|
|
187
|
+
limit?: number;
|
|
188
|
+
oldestTimestamp?: Date;
|
|
189
|
+
} = {
|
|
190
|
+
projectId: episode.projectId,
|
|
191
|
+
workspaceChannels: workspaceChannels,
|
|
192
|
+
limit: data.workspaceMessageLimit || 500,
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
if (episode.createdAt) {
|
|
196
|
+
fetchParams.oldestTimestamp = episode.createdAt;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
workspaceMessages =
|
|
200
|
+
await this.getWorkspaceMessagesForEpisode(fetchParams);
|
|
201
|
+
} catch (error) {
|
|
202
|
+
logger.error(`Error fetching workspace messages: ${error}`);
|
|
203
|
+
// Continue without workspace messages
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return {
|
|
208
|
+
episode,
|
|
209
|
+
stateTimeline,
|
|
210
|
+
internalNotes,
|
|
211
|
+
memberIncidents,
|
|
212
|
+
workspaceMessages,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
@CaptureSpan()
|
|
217
|
+
public static formatEpisodeContextForPostmortem(
|
|
218
|
+
contextData: IncidentEpisodeContextData,
|
|
219
|
+
template?: string,
|
|
220
|
+
): AIGenerationContext {
|
|
221
|
+
const {
|
|
222
|
+
episode,
|
|
223
|
+
stateTimeline,
|
|
224
|
+
internalNotes,
|
|
225
|
+
memberIncidents,
|
|
226
|
+
workspaceMessages,
|
|
227
|
+
} = contextData;
|
|
228
|
+
|
|
229
|
+
let contextText: string = "";
|
|
230
|
+
|
|
231
|
+
// Basic episode information
|
|
232
|
+
contextText += "# Incident Episode Information\n\n";
|
|
233
|
+
contextText += `**Episode Number:** #${episode.episodeNumber || "N/A"}\n\n`;
|
|
234
|
+
contextText += `**Title:** ${episode.title || "N/A"}\n\n`;
|
|
235
|
+
contextText += `**Description:** ${episode.description || "N/A"}\n\n`;
|
|
236
|
+
contextText += `**Severity:** ${episode.incidentSeverity?.name || "N/A"}\n\n`;
|
|
237
|
+
contextText += `**Current State:** ${episode.currentIncidentState?.name || "N/A"}\n\n`;
|
|
238
|
+
contextText += `**Created At:** ${episode.createdAt ? OneUptimeDate.getDateAsFormattedString(episode.createdAt) : "N/A"}\n\n`;
|
|
239
|
+
|
|
240
|
+
// Labels
|
|
241
|
+
if (episode.labels && episode.labels.length > 0) {
|
|
242
|
+
contextText += "**Labels:** ";
|
|
243
|
+
contextText += episode.labels
|
|
244
|
+
.map((l: { name?: string }) => {
|
|
245
|
+
return l.name;
|
|
246
|
+
})
|
|
247
|
+
.join(", ");
|
|
248
|
+
contextText += "\n\n";
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// Root cause if available
|
|
252
|
+
if (episode.rootCause) {
|
|
253
|
+
contextText += `**Root Cause:** ${episode.rootCause}\n\n`;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// Remediation notes if available
|
|
257
|
+
if (episode.remediationNotes) {
|
|
258
|
+
contextText += `**Remediation Notes:** ${episode.remediationNotes}\n\n`;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// Member incidents
|
|
262
|
+
if (memberIncidents.length > 0) {
|
|
263
|
+
contextText += "# Member Incidents\n\n";
|
|
264
|
+
contextText += `This episode contains ${memberIncidents.length} incident(s):\n\n`;
|
|
265
|
+
|
|
266
|
+
for (const member of memberIncidents) {
|
|
267
|
+
const incident: Incident | undefined = member.incident;
|
|
268
|
+
if (!incident) {
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
contextText += `## Incident #${incident.incidentNumber || "N/A"}: ${incident.title || "Untitled"}\n\n`;
|
|
273
|
+
contextText += `- **Severity:** ${incident.incidentSeverity?.name || "N/A"}\n`;
|
|
274
|
+
contextText += `- **State:** ${incident.currentIncidentState?.name || "N/A"}\n`;
|
|
275
|
+
contextText += `- **Created:** ${incident.createdAt ? OneUptimeDate.getDateAsFormattedString(incident.createdAt) : "N/A"}\n`;
|
|
276
|
+
|
|
277
|
+
if (incident.description) {
|
|
278
|
+
contextText += `- **Description:** ${incident.description}\n`;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
if (incident.monitors && incident.monitors.length > 0) {
|
|
282
|
+
contextText += `- **Affected Monitors:** ${incident.monitors
|
|
283
|
+
.map((m: { name?: string }) => {
|
|
284
|
+
return m.name;
|
|
285
|
+
})
|
|
286
|
+
.join(", ")}\n`;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
if (incident.rootCause) {
|
|
290
|
+
contextText += `- **Root Cause:** ${incident.rootCause}\n`;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
if (incident.remediationNotes) {
|
|
294
|
+
contextText += `- **Remediation:** ${incident.remediationNotes}\n`;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
contextText += "\n";
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// State timeline
|
|
302
|
+
if (stateTimeline.length > 0) {
|
|
303
|
+
contextText += "# Episode State Timeline\n\n";
|
|
304
|
+
for (const timeline of stateTimeline) {
|
|
305
|
+
const startTime: string = timeline.startsAt
|
|
306
|
+
? OneUptimeDate.getDateAsFormattedString(timeline.startsAt)
|
|
307
|
+
: "N/A";
|
|
308
|
+
const stateName: string =
|
|
309
|
+
timeline.incidentState?.name?.toString() || "Unknown";
|
|
310
|
+
const createdBy: string =
|
|
311
|
+
timeline.createdByUser?.name?.toString() ||
|
|
312
|
+
timeline.createdByUser?.email?.toString() ||
|
|
313
|
+
"System";
|
|
314
|
+
|
|
315
|
+
contextText += `- **${startTime}**: State changed to **${stateName}** by ${createdBy}\n`;
|
|
316
|
+
if (timeline.rootCause) {
|
|
317
|
+
contextText += ` - Root cause noted: ${timeline.rootCause}\n`;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
contextText += "\n";
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// Internal notes
|
|
324
|
+
if (internalNotes.length > 0) {
|
|
325
|
+
contextText += "# Internal Notes (Private)\n\n";
|
|
326
|
+
for (const note of internalNotes) {
|
|
327
|
+
const noteTime: string = note.createdAt
|
|
328
|
+
? OneUptimeDate.getDateAsFormattedString(note.createdAt)
|
|
329
|
+
: "N/A";
|
|
330
|
+
const createdBy: string =
|
|
331
|
+
note.createdByUser?.name?.toString() ||
|
|
332
|
+
note.createdByUser?.email?.toString() ||
|
|
333
|
+
"Unknown";
|
|
334
|
+
|
|
335
|
+
contextText += `**[${noteTime}] ${createdBy}:**\n`;
|
|
336
|
+
contextText += `${note.note || "N/A"}\n\n`;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// Workspace messages (Slack/Teams)
|
|
341
|
+
if (workspaceMessages.length > 0) {
|
|
342
|
+
contextText += "# Discussion from Episode Channel\n\n";
|
|
343
|
+
contextText += WorkspaceUtil.formatMessagesAsContext(workspaceMessages, {
|
|
344
|
+
includeTimestamp: true,
|
|
345
|
+
includeUsername: true,
|
|
346
|
+
maxLength: 30000,
|
|
347
|
+
});
|
|
348
|
+
contextText += "\n\n";
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// System prompt for postmortem generation
|
|
352
|
+
let systemPrompt: string;
|
|
353
|
+
|
|
354
|
+
if (template) {
|
|
355
|
+
// When a template is provided, strictly fill only the template
|
|
356
|
+
systemPrompt = `You are an expert Site Reliability Engineer (SRE) and incident response specialist. Your task is to fill in an incident episode postmortem template based on the provided episode data.
|
|
357
|
+
|
|
358
|
+
An incident episode is a grouping of related incidents that occurred together or share a common cause.
|
|
359
|
+
|
|
360
|
+
CRITICAL INSTRUCTIONS:
|
|
361
|
+
- You MUST use ONLY the exact template structure provided below
|
|
362
|
+
- Fill in each section of the template with relevant information from the episode data
|
|
363
|
+
- Do NOT add any new sections, headers, or content that is not part of the template
|
|
364
|
+
- Do NOT add introductions, conclusions, or any text outside the template structure
|
|
365
|
+
- If a section in the template has no relevant data, write "No data available" or leave the placeholder text
|
|
366
|
+
- Be blameless - focus on systemic improvements rather than individual blame
|
|
367
|
+
- Write in a professional, clear, and concise manner
|
|
368
|
+
- Consider all member incidents when analyzing root cause and impact
|
|
369
|
+
|
|
370
|
+
TEMPLATE TO FILL (use this exact structure):
|
|
371
|
+
|
|
372
|
+
${template}`;
|
|
373
|
+
} else {
|
|
374
|
+
// When no template is provided, use standard format
|
|
375
|
+
systemPrompt = `You are an expert Site Reliability Engineer (SRE) and incident response specialist. Your task is to generate a comprehensive, well-structured postmortem for an incident episode based on the provided data.
|
|
376
|
+
|
|
377
|
+
An incident episode is a grouping of related incidents that occurred together or share a common cause.
|
|
378
|
+
|
|
379
|
+
The postmortem should:
|
|
380
|
+
1. Be written in a blameless manner, focusing on systemic improvements rather than individual blame
|
|
381
|
+
2. Include a clear executive summary that covers all member incidents
|
|
382
|
+
3. Provide a detailed timeline of events across all incidents
|
|
383
|
+
4. Identify the common root cause(s) and contributing factors
|
|
384
|
+
5. Outline the cumulative impact on users and systems
|
|
385
|
+
6. List actionable items to prevent recurrence of similar episodes
|
|
386
|
+
7. Include lessons learned from the entire episode
|
|
387
|
+
|
|
388
|
+
Use a standard incident postmortem format with sections for: Executive Summary, Timeline, Root Cause Analysis, Impact, Action Items, and Lessons Learned.
|
|
389
|
+
|
|
390
|
+
Write in a professional, clear, and concise manner. Use markdown formatting for better readability.`;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
// Build user message based on whether template is provided
|
|
394
|
+
const userMessage: string = template
|
|
395
|
+
? `Fill in the template above using ONLY the following incident episode data. Output only the filled template, nothing else:\n\n${contextText}`
|
|
396
|
+
: `Based on the following incident episode data, please generate a comprehensive postmortem:\n\n${contextText}`;
|
|
397
|
+
|
|
398
|
+
// Build messages array
|
|
399
|
+
const messages: Array<LLMMessage> = [
|
|
400
|
+
{
|
|
401
|
+
role: "system",
|
|
402
|
+
content: systemPrompt,
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
role: "user",
|
|
406
|
+
content: userMessage,
|
|
407
|
+
},
|
|
408
|
+
];
|
|
409
|
+
|
|
410
|
+
return {
|
|
411
|
+
contextText,
|
|
412
|
+
systemPrompt,
|
|
413
|
+
messages,
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
@CaptureSpan()
|
|
418
|
+
private static async getWorkspaceMessagesForEpisode(data: {
|
|
419
|
+
projectId: ObjectID;
|
|
420
|
+
workspaceChannels: Array<NotificationRuleWorkspaceChannel>;
|
|
421
|
+
limit?: number;
|
|
422
|
+
oldestTimestamp?: Date;
|
|
423
|
+
}): Promise<Array<WorkspaceChannelMessage>> {
|
|
424
|
+
const allMessages: Array<WorkspaceChannelMessage> = [];
|
|
425
|
+
|
|
426
|
+
for (const channel of data.workspaceChannels) {
|
|
427
|
+
try {
|
|
428
|
+
// Get auth token for this workspace type
|
|
429
|
+
const projectAuth: WorkspaceProjectAuthToken | null =
|
|
430
|
+
await WorkspaceProjectAuthTokenService.getProjectAuth({
|
|
431
|
+
projectId: data.projectId,
|
|
432
|
+
workspaceType: channel.workspaceType,
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
if (!projectAuth || !projectAuth.authToken) {
|
|
436
|
+
logger.debug(
|
|
437
|
+
`No auth token found for workspace type: ${channel.workspaceType}`,
|
|
438
|
+
);
|
|
439
|
+
continue;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
const messagesParams: {
|
|
443
|
+
channelId: string;
|
|
444
|
+
authToken: string;
|
|
445
|
+
projectId: ObjectID;
|
|
446
|
+
workspaceType: WorkspaceType;
|
|
447
|
+
teamId?: string;
|
|
448
|
+
limit?: number;
|
|
449
|
+
oldestTimestamp?: Date;
|
|
450
|
+
} = {
|
|
451
|
+
channelId: channel.id,
|
|
452
|
+
authToken: projectAuth.authToken,
|
|
453
|
+
projectId: data.projectId,
|
|
454
|
+
workspaceType: channel.workspaceType,
|
|
455
|
+
};
|
|
456
|
+
|
|
457
|
+
if (channel.teamId) {
|
|
458
|
+
messagesParams.teamId = channel.teamId;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
if (data.limit !== undefined) {
|
|
462
|
+
messagesParams.limit = data.limit;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
if (data.oldestTimestamp) {
|
|
466
|
+
messagesParams.oldestTimestamp = data.oldestTimestamp;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
const messages: Array<WorkspaceChannelMessage> =
|
|
470
|
+
await WorkspaceUtil.getChannelMessages(messagesParams);
|
|
471
|
+
|
|
472
|
+
allMessages.push(...messages);
|
|
473
|
+
} catch (error) {
|
|
474
|
+
logger.error(
|
|
475
|
+
`Error fetching messages from channel ${channel.id}: ${error}`,
|
|
476
|
+
);
|
|
477
|
+
// Continue with other channels even if one fails
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
// Sort all messages by timestamp
|
|
482
|
+
allMessages.sort(
|
|
483
|
+
(a: WorkspaceChannelMessage, b: WorkspaceChannelMessage) => {
|
|
484
|
+
return a.timestamp.getTime() - b.timestamp.getTime();
|
|
485
|
+
},
|
|
486
|
+
);
|
|
487
|
+
|
|
488
|
+
return allMessages;
|
|
489
|
+
}
|
|
490
|
+
}
|