I have requirement to calculate total time a user has been connected to system, for that I have logs as below which stats that when user connected and disconnected, how can we calculate his total time connected by userId. {
"timestamp": "2024-02-19T20:15:01,544Z",
"message": "Connection created.",
"sessionId": "383c4345",
"operation": "Connect",
"spanId": "578045e3cfdbb598",
"traceId": "578045e3cfdbb598",
"userId": "test12"
}
{
"timestamp": "2024-02-19T21:19:01,544Z",
"message": "Connection disconnected.",
"sessionId": "383c4345",
"operation": "Disconnect",
"spanId": "578045e3cfdbb598",
"traceId": "578045e3cfdbb598",
"userId": "test12"
}
{
"timestamp": "2024-02-19T22:24:01,544Z",
"message": "Connection created.",
"sessionId": "383cxfe45",
"operation": "Connect",
"spanId": "fdcaf3d14e630be3",
"traceId": "fdcaf3d14e630be3",
"userId": "test12"
}
{
"timestamp": "2024-02-19T23:17:01,544Z",
"message": "Connection disconnected.",
"sessionId": "383cxfe45",
"operation": "Disconnect",
"spanId": "fdcaf3d14e630be3",
"traceId": "fdcaf3d14e630be3",
"userId": "test12"
}
{
"timestamp": "2024-02-19T19:45:01,544Z",
"message": "Connection created.",
"sessionId": "7490647a",
"operation": "Connect",
"spanId": "c6cc6afa1a770fc9",
"traceId": "c6cc6afa1a770fc9",
"userId": "test_234"
}
{
"timestamp": "2024-02-19T20:19:01,544Z",
"message": "Connection disconnected.",
"sessionId": "7490647a",
"operation": "Disconnect",
"spanId": "c6cc6afa1a770fc9",
"traceId": "c6cc6afa1a770fc9",
"userId": "test_234"
}
{
"timestamp": "2024-02-19T21:34:01,544Z",
"message": "Connection created.",
"sessionId": "f9cbd2f",
"operation": "Connect",
"spanId": "fdcaf3d14e630be3",
"traceId": "fdcaf3d14e630be3",
"userId": "test_234"
}
{
"timestamp": "2024-02-19T23:20:01,544Z",
"message": "Connection disconnected.",
"sessionId": "f9cbd2f",
"operation": "Disconnect",
"spanId": "fdcaf3d14e630be3",
"traceId": "fdcaf3d14e630be3",
"userId": "test_234"
} Have given example for 2 userId test12 and test_234, has connected /disconnected 2 times. And I am expecting results as below. User Total Time Connected test12 1 hour 59 min test_234 2 hours 20 min
... View more