Get the client id that is generated every time the application starts in Realm MongoDB

Hello, I am trying to obtain the client id that is generated every time the application starts, which I can observe in the logs (Connected to app services with request id: …), without having to obtain it directly from the message

The question is a little vague and you should really include the code you’ve attempted and are having difficulty with.

What is a ‘client id’ in this use case. The App ID?

Then what is ‘the message’ - which message are you referring to?

Sorry for explaining myself wrong, what I need is to save the history of all the request ids (which are generated every time the application starts) of each user, so I would like to know if there is a way to get that id without having to get it from the log

Hi @rivars,

Those request IDs correlate to the co_id field in your App Services logs, which can be retrieved via the admin API: MongoDB Atlas App Services Admin API

I am curious to hear more about your use case since those request IDs identify the websocket connection, which can be opened/closed multiple times over the course of a realm’s lifetime. It should not be considered a stable identifier of an app session.

Use case aside, the recommended way to accomplish what you’re trying to do would be to set up a log forwarder in your App Services backend. You could forward sync logs to a function that filters out the SYNC_CONNECTION_START log entries and extracts the user_id and co_id fields from each entry.