@@ -25,7 +25,7 @@ type GenericAuditFields struct {
2525 Component string `json:"component"`
2626 FolderID string `json:"folder_id"`
2727 Subject string `json:"subject"`
28- SanitizedToken string `json:"sanitized_token"`
28+ SanitizedToken string `json:"sanitized_token,omitempty "`
2929 Status string `json:"status"`
3030 Reason string `json:"reason,omitempty"`
3131 Timestamp string `json:"@timestamp"`
@@ -198,18 +198,58 @@ func ReportBackupStateAuditEvent(
198198 Component : "backup_service" ,
199199 FolderID : operation .GetContainerID (),
200200 Subject : types .OperationCreatorName ,
201- SanitizedToken : "<somehow unpack token from oauth2 auth process>" ,
202- Status : status ,
203- Reason : reason ,
204- Timestamp : time .Now ().Format (time .RFC3339Nano ),
205- IsBackground : true ,
201+ //no token
202+ Status : status ,
203+ Reason : reason ,
204+ Timestamp : time .Now ().Format (time .RFC3339Nano ),
205+ IsBackground : true ,
206206 },
207207 Database : operation .GetDatabaseName (),
208208 }
209209
210210 ReportAuditEvent (ctx , event )
211211}
212212
213+ type FailedRPOAuditEvent struct {
214+ GenericAuditFields
215+ Database string `json:"database"`
216+ ScheduleID string `json:"schedule_id"`
217+ }
218+
219+ var ReportedMissedRPOs = make (map [string ]bool )
220+
221+ func ReportFailedRPOAuditEvent (ctx context.Context , schedule * types.BackupSchedule ) {
222+ if schedule == nil {
223+ xlog .Error (ctx , "nil schedule passed to ReportFailedRPOAuditEvent" )
224+ return
225+ }
226+ if ReportedMissedRPOs [schedule .ID ] {
227+ return
228+ }
229+ event := & FailedRPOAuditEvent {
230+ GenericAuditFields : GenericAuditFields {
231+ ID : uuid .New ().String (),
232+ IdempotencyKey : schedule .ID ,
233+ Service : "ydbcp" ,
234+ SpecVersion : "1.0" ,
235+ Action : ActionGet ,
236+ Resource : BackupSchedule ,
237+ Component : "backup_service" ,
238+ FolderID : schedule .ContainerID ,
239+ Subject : types .OperationCreatorName ,
240+ //no token
241+ Status : "ERROR" ,
242+ Reason : "Recovery point objective failed for schedule" ,
243+ Timestamp : time .Now ().Format (time .RFC3339Nano ),
244+ IsBackground : true ,
245+ },
246+ Database : schedule .DatabaseName ,
247+ ScheduleID : schedule .ID ,
248+ }
249+ ReportAuditEvent (ctx , event )
250+ ReportedMissedRPOs [schedule .ID ] = true
251+ }
252+
213253func ReportAuditEvent (ctx context.Context , event any ) {
214254 env , err := makeEnvelope (event )
215255 if err != nil {
0 commit comments