Hi
1. With Oplog i can only find operations, not document diff (correct
me if i am wrong!, like multi update will record query, but not record
which all doc will get updated!)
2. When thinking of audit trail report, put that in different
database. [So while writing audit-trail, it will not block your
regular operations as currently mongodb is having write lock per
database write operation]
3. consider of sharding and overall architecture.
4. I would again go back why one wants to do audit trail? a) to catch
bad user b) to roll back the dirty changes c) just to comply with
audit policy
5. a) and c) are fine, but if you really wants to achieve b) it may
require some hack into mongodb and may be some performance penalty
<it really depends on how many write operations are performed +
document diff size and other factors>
6. Trade-off will be to take daily/hourly backup, and store only
queries causing document changes (instead of document diff. for each
operations!)
PS: you may want to search audit trail in archive of this google group
+ jira + stackoverflow
Thanks
Raxit Sheth
On Dec 24, 5:36 pm, Anuj Shah <
anuj.pradeep.s...@gmail.com> wrote:
> Hi,
>
> I am trying to model an application specific audit trail and am looking for
> a good approach to do so.
>
> Requirement is to store the following info for audit in a shadow collection:
>
> 1. docId: ObjectId of the changed document
> 2. on: date-time stamp of change
> 3. by: Application's user's ObjectId
> 4. event: Application specific event / action that caused this change
> 5. changes: an object hash of all changes to the document. For
> example: document has properties { Style: "Men's Bottoms / Work /
> Carpenter", Color: "Khaki" }, Color is changed to Blue, then this hash will
> look like: changes: { Color: { inserted: "Blue", retracted: "Khaki" } }
>
> To achieve the following I can think of needing the ability to identify a
> change event and a document diff. A change event can be identified at the
> app layer, but it would really help to have an efficient document diff
> facility. Any pointers?
>
> Note that I thought of using the oplog, but the issue would be to tie the
> change with an application user / event.
>
> If someone has a better approach, please recommend.
>
> Thanks!