Skip to content

Commit 92637cb

Browse files
committed
Add connected_at field to $events/client_disconected
1 parent 04455ca commit 92637cb

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

en_US/data-integration/rule-sql-events-and-fields.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,14 +332,15 @@ Refer to the table below for fields that can be selected from the received MQTT
332332

333333
This event topic can be used to trigger a rule when a client is disconnected.
334334

335-
For example, you can use the statement below to extract data from the `"$events/client_disconnected"` event topic that includes the following data fields: client ID, username, disconnect reason, disconnect time, and EMQX node where the event is triggered.
335+
For example, you can use the statement below to extract data from the `"$events/client_disconnected"` event topic that includes the following data fields: client ID, username, disconnect reason, connection start time, disconnect time, and EMQX node where the event is triggered.
336336

337337
Example:
338338
```sql
339339
SELECT
340340
clientid,
341341
username,
342342
reason,
343+
connected_at,
343344
disconnected_at,
344345
node
345346
FROM
@@ -351,20 +352,20 @@ Output:
351352
"username": "u_emqx",
352353
"reason": "normal",
353354
"node": "[email protected]",
355+
"connected_at": 1645003578036,
354356
"disconnected_at": 1645003578536,
355357
"clientid": "c_emqx"
356358
}
357359
```
358360

359-
360-
361361
| Field | Explanation |
362362
| :---------------- | :----------------------------------------------------------- |
363363
| `reason` | Disconnect reasons<br/><br/>`normal`: The client is intentionally disconnected <br/><br/>`kicked`: EMQX has forcibly removed the client through REST API<br/><br/>`keepalive_timeout`: The specified keepalive time period expired.<br/><br/>`not_authorized`: Authorization failed.<br/><br/>`tcp_closed`: The peer has closed network connection.<br/><br/>`discarded`: Another client ( with `clean_start` set to `true`) connected with the same ClientID, causing the previous connection to be dropped.<br/><br/>`takenover`: Another client ( with `clean_start` set to `false`) connected with the same ClientID, taking over the previous connection..<br/><br/>`internal_error`: An error has occurred due to an improperly formatted message or other unknown issues. |
364364
| `clientid` | Client ID |
365365
| `username` | Client username |
366366
| `peername` | IP Address and Port number |
367367
| `sockname` | IP Address and Port number listened by EMQX |
368+
| `connected_at` | Client connection start time (unit: ms). This timestamp represents when the current session was established and helps identify which connection session the disconnect event belongs to.<br />It ensures that delayed disconnect events do not overwrite newer connection states. |
368369
| `disconnected_at` | Client disconnection completion time (unit: ms) |
369370
| `disconn_props` | DISCONNECT Properties (MQTT 5.0 clients only) |
370371
| `timestamp` | Event trigger time (unit: ms) |

zh_CN/data-integration/rule-sql-events-and-fields.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ FROM
347347
| username | 消息目的用户名 |
348348
| peername | 客户端的 IPAddress 和 Port |
349349
| sockname | emqx 监听的 IPAddress 和 Port |
350+
| connected_at | 客户端连接开始时间(单位:毫秒)。该时间戳表示当前会话建立的时间,有助于识别断开事件所属的连接会话。<br />此字段可确保延迟的断开事件不会覆盖较新的连接状态。 |
350351
| disconnected\_at | 客户端连接断开时间 (单位:毫秒) |
351352
| disconn\_props | DISCONNECT Properties (仅适用于 MQTT 5.0) |
352353
| timestamp | 事件触发时间 (单位:毫秒) |
@@ -360,6 +361,7 @@ SELECT
360361
clientid,
361362
username,
362363
reason,
364+
connected_at,
363365
disconnected_at,
364366
node
365367
FROM
@@ -373,6 +375,7 @@ FROM
373375
"username": "u_emqx",
374376
"reason": "normal",
375377
"node": "[email protected]",
378+
"connected_at": 1645003578036,
376379
"disconnected_at": 1645003578536,
377380
"clientid": "c_emqx"
378381
}

0 commit comments

Comments
 (0)