Consuming the Audit Service

Once you have set up the audit service and started logging audit entries, you can view them using a custom REST client.

Using a custom REST client

To view audit entries using a custom REST client, you can make POST requests to the following endpoints. These endpoints are POST requests because they accept a request body to apply server-side filters to the timestamp field. These endpoints return a list of all audit entries in JSON format.

note

We recommend enabling the Swagger UI in your application to easily explore and trigger the API endpoints.

  • /audit-service/rest/v1/audit-entries: returns a list of all audit entries
  • /audit-service/rest/v1/audit-entries/type: returns a list of all audit entries by type
  • /audit-service/rest/v1/audit-entries/type/objectId: returns a list of all audit entries by type and objectId

The filter body has the following format:

[
  {
    "fieldName": "string", // should be "timestamp" but may be expanded to other fields in future
    "filterType": "BETWEEN", // options are "BETWEEN", "GREATER_THAN", and "LESS_THAN"
    "filterValue": {} // should be a 2-element list for "BETWEEN", or a single ZonedDateTime for "GREATER_THAN" and "LESS_THAN"
  }
]

You can see all available types by executing the GET request /audit-service/rest/v1/audit-entries/types, which will return a String list in JSON format.