Showing
3 changed files
with
7 additions
and
5 deletions
... | ... | @@ -323,8 +323,11 @@ audit_log: |
323 | 323 | # Name of the index where audit logs stored |
324 | 324 | # Index name could contain next placeholders (not mandatory): |
325 | 325 | # @{TENANT} - substituted by tenant ID |
326 | - # @{DATE} - substituted by current date in YYYY.MM.DD format | |
326 | + # @{DATE} - substituted by current date in format provided in audit_log.sink.date_format | |
327 | 327 | index_pattern: "${AUDIT_LOG_SINK_INDEX_PATTERN:@{TENANT}_AUDIT_LOG_@{DATE}}" |
328 | + # Date format. Details of the pattern could be found here: | |
329 | + # https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html | |
330 | + date_format: "${AUDIT_LOG_SINK_DATE_FORMAT:YYYY.MM.DD}" | |
328 | 331 | scheme_name: "${AUDIT_LOG_SINK_SCHEME_NAME:http}" # http or https |
329 | 332 | host: "${AUDIT_LOG_SINK_HOST:localhost}" |
330 | 333 | port: "${AUDIT_LOG_SINK_POST:9200}" | ... | ... |
... | ... | @@ -300,7 +300,6 @@ public class AuditLogServiceImpl implements AuditLogService { |
300 | 300 | futures.add(auditLogDao.saveByTenantIdAndCustomerId(auditLogEntry)); |
301 | 301 | futures.add(auditLogDao.saveByTenantIdAndUserId(auditLogEntry)); |
302 | 302 | |
303 | - // TODO: is this correct place to log action into sink? | |
304 | 303 | auditLogSink.logAction(auditLogEntry); |
305 | 304 | |
306 | 305 | return Futures.allAsList(futures); | ... | ... |
... | ... | @@ -50,8 +50,6 @@ public class ElasticsearchAuditLogSink implements AuditLogSink { |
50 | 50 | |
51 | 51 | private static final String TENANT_PLACEHOLDER = "@{TENANT}"; |
52 | 52 | private static final String DATE_PLACEHOLDER = "@{DATE}"; |
53 | - private static final String DATE_FORMAT = "YYYY.MM.dd"; | |
54 | - | |
55 | 53 | private static final String INDEX_TYPE = "audit_log"; |
56 | 54 | |
57 | 55 | private final ObjectMapper mapper = new ObjectMapper(); |
... | ... | @@ -68,6 +66,8 @@ public class ElasticsearchAuditLogSink implements AuditLogSink { |
68 | 66 | private String userName; |
69 | 67 | @Value("${audit_log.sink.password}") |
70 | 68 | private String password; |
69 | + @Value("${audit_log.sink.date_format}") | |
70 | + private String dateFormat; | |
71 | 71 | |
72 | 72 | private RestClient restClient; |
73 | 73 | |
... | ... | @@ -152,7 +152,7 @@ public class ElasticsearchAuditLogSink implements AuditLogSink { |
152 | 152 | } |
153 | 153 | if (indexName.contains(DATE_PLACEHOLDER)) { |
154 | 154 | LocalDateTime now = LocalDateTime.now(); |
155 | - DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_FORMAT); | |
155 | + DateTimeFormatter formatter = DateTimeFormatter.ofPattern(dateFormat); | |
156 | 156 | indexName = indexName.replace(DATE_PLACEHOLDER, now.format(formatter)); |
157 | 157 | } |
158 | 158 | return indexName.toLowerCase(); | ... | ... |