We have microservice architecture application in spring boot. We are planning to add an audit logs to our services. So that we can get the information like,
- Admin123 deactivated User123
- User123 changed the password
- User123 logged in
High level:
- For this we are planning to write the required info into a log file as a JSON format. (Each service logs will be maintained separately)
- Then Devops team, uses Filebeat to read and pushes the logs to elastic search.
- And then we can query/visualize the information from elastic search using kibana.
JSON (log structure):
{
"userId" : "100",
"ip" : "192.168.1.1",
"deviceId" : "f07a13984f6d116a",
"country" : "India",
"language" : "English (U.S)"
"userAgent" : "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36",
"timestamp" : "2004-02-12T15:19:21.000+00:00",
"event" : "update product",
"resource" : "user",
"action" : "deactivate",
"objectId" : "22",
"objectType" : "user",
"description" : "Deactivated user",
"service" : "User service",
"appVersion" : "v1",
"requestId" : "db176f6b-b4c6-4a59-ac62-4d471eedf354"
"server" : "i0e5b5c88",
"serverLocation": "us-east-1",
"protocol" : "https",
"method" : "PATCH",
"statusCode" : "200"
}
Can anyone suggest better architecture to achieve custom audit logs using spring boot?
So that I can extract the useful information out of it.