Also, what other factors need to be considered when implementing audit trail?
Ask HN: How do you implement audit trail for a product?
1–10 of 18 posts
Re: Ask HN: How do you implement audit trail for a product?
#2In short, IIRC, it looks into the RDBMSs redo log, and turns it into a message stream. You can then stream this into some kind of messaging platform (Kakfa is typical) and then process the data any way you want. Log it, aggregate it, archive it, stick it in another database, or object store, etc...
Re: Ask HN: How do you implement audit trail for a product?
#3Because audit trails record activity, I would generally recommend linking the audit trail to the API call site rather than the database, as you should include information such as the actor (who made the call/request) and context (e.g. what IP address and user agent the call came from). An additional good practice is to add the request and response of the API call being recorded. You should also redact any sensitive or PII fields.
If you're looking for a managed service that takes care of all of this, and delivering it to your customers for you, check out https://apptrail.com (Disclaimer: founder).
Re: Ask HN: How do you implement audit trail for a product?
#4Re: Ask HN: How do you implement audit trail for a product?
#5Re: Ask HN: How do you implement audit trail for a product?
#6INSERT only, no UPDATEs. Queries return most recent record. Periodically groom older entries.
If you want to get just a bit more fancy, add a hash that depends on previous entries, like some sort of proto-blockchain.
Re: Ask HN: How do you implement audit trail for a product?
#7I think the best pattern for this is Change Data Capture (CDC). Checkout out something like Debezium. In short, IIRC, it looks into the RDBMSs redo log, and turns it into a message stream. You can then stream this into some kind of messaging platform (Kakfa is typical) and then process the data any way you want. Log it, aggregate it, archive it, stick it in another database, or object store, etc...
Re: Ask HN: How do you implement audit trail for a product?
#8Re: Ask HN: How do you implement audit trail for a product?
#9I think the best pattern for this is Change Data Capture (CDC). Checkout out something like Debezium. In short, IIRC, it looks into the RDBMSs redo log, and turns it into a message stream. You can then stream this into some kind of messaging platform (Kakfa is typical) and then process the data any way you want. Log it, aggregate it, archive it, stick it in another database, or object store, etc...
How would CDC include information like the user making the change?
Re: Ask HN: How do you implement audit trail for a product?
#10INSERT only, no UPDATEs. Queries return most recent record. Periodically groom older entries.