会话 (sessions)
sessions 端点提供了由 Spring Session 管理的应用程序 HTTP 会话信息。
检索会话
要检索会话,请向 /actuator/sessions 发送 GET 请求,如以下基于 curl 的示例所示
$ curl 'https://:8080/actuator/sessions?username=alice' -i -X GET
前面的示例检索了用户名为 alice 的所有会话。结果响应类似于以下内容
HTTP/1.1 200 OK
Content-Type: application/vnd.spring-boot.actuator.v3+json
Content-Length: 789
{
"sessions" : [ {
"attributeNames" : [ ],
"creationTime" : "2025-11-20T14:33:59.914866807Z",
"expired" : false,
"id" : "40b429f0-57dd-4aeb-a5ad-241bea75fcb7",
"lastAccessedTime" : "2025-11-20T16:33:47.914867419Z",
"maxInactiveInterval" : 1800
}, {
"attributeNames" : [ ],
"creationTime" : "2025-11-20T04:33:59.914198661Z",
"expired" : false,
"id" : "13bd41f7-d039-4969-87bf-298833e7d86d",
"lastAccessedTime" : "2025-11-20T16:33:14.914204682Z",
"maxInactiveInterval" : 1800
}, {
"attributeNames" : [ ],
"creationTime" : "2025-11-20T11:33:59.914862470Z",
"expired" : false,
"id" : "4db5efcc-99cb-4d05-a52c-b49acfbb7ea9",
"lastAccessedTime" : "2025-11-20T16:33:22.914864303Z",
"maxInactiveInterval" : 1800
} ]
}
响应结构
响应包含匹配会话的详细信息。下表描述了响应的结构
| 路径 | 类型 | 描述 |
|---|---|---|
|
|
给定用户名的会话。 |
|
|
会话 ID。 |
|
|
存储在会话中的属性名称。 |
|
|
会话创建的时间戳。 |
|
|
会话上次访问的时间戳。 |
|
|
会话过期前的最大允许非活动时间,单位为秒。 |
|
|
会话是否已过期。 |
检索单个会话
要检索单个会话,请向 /actuator/sessions/{id} 发送 GET 请求,如以下基于 curl 的示例所示
$ curl 'https://:8080/actuator/sessions/4db5efcc-99cb-4d05-a52c-b49acfbb7ea9' -i -X GET
前面的示例检索了 ID 为 4db5efcc-99cb-4d05-a52c-b49acfbb7ea9 的会话。结果响应类似于以下内容
HTTP/1.1 200 OK
Content-Type: application/vnd.spring-boot.actuator.v3+json
Content-Length: 208
{"attributeNames":[],"creationTime":"2025-11-20T11:33:59.914862470Z","expired":false,"id":"4db5efcc-99cb-4d05-a52c-b49acfbb7ea9","lastAccessedTime":"2025-11-20T16:33:22.914864303Z","maxInactiveInterval":1800}