审计事件 (auditevents)

审计事件端点提供了有关应用程序审计事件的信息。

检索审计事件

要检索审计事件,请向 /actuator/auditevents 发送 GET 请求,如下所示的基于 curl 的示例:

curl 'http://localhost:8080/actuator/auditevents?principal=alice&after=2024-08-22T16%3A49%3A59.642365836Z&type=logout' -i -X GET

上述示例检索了在 2017 年 11 月 7 日 UTC 时区 09:37 之后发生的,针对主体 alicelogout 事件。 得到的响应类似于以下内容:

HTTP/1.1 200 OK
Content-Type: application/vnd.spring-boot.actuator.v3+json
Content-Length: 127

{
  "events" : [ {
    "timestamp" : "2024-08-22T16:49:59.648097254Z",
    "principal" : "alice",
    "type" : "logout"
  } ]
}

查询参数

端点使用查询参数来限制它返回的事件。 下表显示了支持的查询参数:

参数

描述

after

限制返回给定时间之后发生的事件。可选。

principal

限制返回给定主体的事件。可选。

type

限制返回给定类型的事件。可选。

响应结构

响应包含所有符合查询条件的审计事件的详细信息。下表描述了响应的结构:

路径

类型

描述

events

Array

一个审计事件的数组。

events.[].timestamp

String

事件发生的时间戳。

events.[].principal

String

触发该事件的主体。

events.[].type

String

事件的类型。