Overview

The audit log service collects messages from the services used across the SaFi Bank system. Audit logs record the occurrence of an event, the time at which it occurred, the responsible customer or agent, the impacted entity etc.

Requirements

Data Sources

  • For change history

    • Core Backend Services

  • For communication history

    • Communication gateway(s) - email, SMS, notifications …

    • Call centre - calls

Audit log architecture

  • All components are able to emit audit log command messages

  • The audit-log-manager processes and stores them

  • The audit-log-manager also allows access and filtering of the data

Note about naming: Historically, the entity received and processed by the audit log is called “Event”, though the messages sent to the audit log are of the “Command” type not “Event” type.

A better name would be “Activity”, but both the BE and FE refers to the audit log records as “audit log events” or just “events”.

API

POST /auditlog/events/v2      // Returns the audit log events based on criteria

Note that this is a POST endpoint in order to support a request body with a complex filter:

{
  "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "sourceId": "string",
  "sourceType": "CUSTOMER_USER",
  "sourceEntityMeta": {
    "additionalProp1": {}
  },
  "action": "COMMUNICATED",
  "targetId": "string",
  "targetType": [
    "CUSTOMER"
  ],
  "targetEntityMeta": {
    "additionalProp1": {}
  },
  "timeFrom": "2022-11-24T13:26:35.213Z",
  "timeTo": "2022-11-24T13:26:35.213Z",
  "detail": {
    "additionalProp1": "string",
    "additionalProp2": "string",
    "additionalProp3": "string"
  }
}

Data model

Audit log data model

Implementation

The service

  1. Listens for backoffice.create-audit-log.command.{version} events

  2. Adds missing metadata via preprocessors

  3. Stores them in DB.

Kafka messages

As mentioned, the audit-log-manager is the single consumer of audit log command messages.

Usage

Backend: How to send audit log messages

Frontend: Change history - audit log data in BOFE

Open Questions

Question

Answer

Will audit log stare data/events with other logs?

No this will be a separate stream of events in a separate Kafka channel

What DB will the audit log use

Zbyněk Melichar (Unlicensed) suggested https://www.timescale.com/ let’s evaluate that.

Update: IT will not be used see TimescaleDB [not used]

What software tool will be used (eg Google Cloud Logging) or will a custom service be implemented?

Normal microservice is enough

Which type of actions/events will be passed and stored in audit log system?

See data model proposal above

Attachments: