How to identify the db user in changestream event?

Is there any way to identify the DB User in the MongoDB changestream event?

Suppose if two users modify the same document, I am looking for a way to distinguish between these two change events based on the user.

1 Like

Hi @Vittal_Pai ,

The only way to do that is if you add this information as a field to the changed/created document.

In order to audit actions we have logging and auditing capabilities unrelated to change streams…

Thanks
Pavel

Thanks @Pavel_Duchovny for the quick reply.

I am trying to distinguish between operations made by a Kafka connector and others. Is there any other way to achieve this?

Hi @Vittal_Pai ,

Oh alright so you should definitely look into connector sink post processors…

Those are exactly made to rename/add fields before they are written to MongoDB. So you can add some identifier that will let you know the connector wrote it in your change streams

To be honest maybe the one you actually need is already prebuilt : KafkaMetaAdder

Adds a field named “topic-partition-offset” and sets the value to the concatenation of Kafka topic, partition, and offset to the document.

I hope it makes sense.

Best regards
Pavel

Thanks @Pavel_Duchovny for quick help :slight_smile:

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.