Details
diff --git a/application/src/main/resources/thingsboard.yml b/application/src/main/resources/thingsboard.yml
index b421ab1..97da989 100644
--- a/application/src/main/resources/thingsboard.yml
+++ b/application/src/main/resources/thingsboard.yml
@@ -323,8 +323,11 @@ audit_log:
# Name of the index where audit logs stored
# Index name could contain next placeholders (not mandatory):
# @{TENANT} - substituted by tenant ID
- # @{DATE} - substituted by current date in YYYY.MM.DD format
+ # @{DATE} - substituted by current date in format provided in audit_log.sink.date_format
index_pattern: "${AUDIT_LOG_SINK_INDEX_PATTERN:@{TENANT}_AUDIT_LOG_@{DATE}}"
+ # Date format. Details of the pattern could be found here:
+ # https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html
+ date_format: "${AUDIT_LOG_SINK_DATE_FORMAT:YYYY.MM.DD}"
scheme_name: "${AUDIT_LOG_SINK_SCHEME_NAME:http}" # http or https
host: "${AUDIT_LOG_SINK_HOST:localhost}"
port: "${AUDIT_LOG_SINK_POST:9200}"
diff --git a/dao/src/main/java/org/thingsboard/server/dao/audit/AuditLogServiceImpl.java b/dao/src/main/java/org/thingsboard/server/dao/audit/AuditLogServiceImpl.java
index 2d93c16..184e75b 100644
--- a/dao/src/main/java/org/thingsboard/server/dao/audit/AuditLogServiceImpl.java
+++ b/dao/src/main/java/org/thingsboard/server/dao/audit/AuditLogServiceImpl.java
@@ -300,7 +300,6 @@ public class AuditLogServiceImpl implements AuditLogService {
futures.add(auditLogDao.saveByTenantIdAndCustomerId(auditLogEntry));
futures.add(auditLogDao.saveByTenantIdAndUserId(auditLogEntry));
- // TODO: is this correct place to log action into sink?
auditLogSink.logAction(auditLogEntry);
return Futures.allAsList(futures);
diff --git a/dao/src/main/java/org/thingsboard/server/dao/audit/sink/ElasticsearchAuditLogSink.java b/dao/src/main/java/org/thingsboard/server/dao/audit/sink/ElasticsearchAuditLogSink.java
index c6a7808..4d3b6b8 100644
--- a/dao/src/main/java/org/thingsboard/server/dao/audit/sink/ElasticsearchAuditLogSink.java
+++ b/dao/src/main/java/org/thingsboard/server/dao/audit/sink/ElasticsearchAuditLogSink.java
@@ -50,8 +50,6 @@ public class ElasticsearchAuditLogSink implements AuditLogSink {
private static final String TENANT_PLACEHOLDER = "@{TENANT}";
private static final String DATE_PLACEHOLDER = "@{DATE}";
- private static final String DATE_FORMAT = "YYYY.MM.dd";
-
private static final String INDEX_TYPE = "audit_log";
private final ObjectMapper mapper = new ObjectMapper();
@@ -68,6 +66,8 @@ public class ElasticsearchAuditLogSink implements AuditLogSink {
private String userName;
@Value("${audit_log.sink.password}")
private String password;
+ @Value("${audit_log.sink.date_format}")
+ private String dateFormat;
private RestClient restClient;
@@ -152,7 +152,7 @@ public class ElasticsearchAuditLogSink implements AuditLogSink {
}
if (indexName.contains(DATE_PLACEHOLDER)) {
LocalDateTime now = LocalDateTime.now();
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_FORMAT);
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern(dateFormat);
indexName = indexName.replace(DATE_PLACEHOLDER, now.format(formatter));
}
return indexName.toLowerCase();