Skip to content

Commit

Permalink
Issue #3187: Properly manage missing storage id in system logs
Browse files Browse the repository at this point in the history
  • Loading branch information
tcibinan committed Apr 13, 2023
1 parent f13c303 commit 3e37755
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,11 @@ private LogEntry mapHitToLogEntry(SearchHit searchHit) {
.user((String) hit.get(USER))
.message((String) hit.get(MESSAGE))
.severity((String) hit.getOrDefault(SEVERITY, DEFAULT_SEVERITY))
.storageId(Optional.ofNullable(hit.get(STORAGE_ID))
.map(Object::toString)
.filter(StringUtils::isNotBlank)
.map(Long::valueOf)
.orElse(null))
.build();
}

Expand Down
2 changes: 1 addition & 1 deletion api/src/main/resources/log4j2-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<KeyValuePair key="user" value="$${ctx:user:-NotAuthorized}" />
<KeyValuePair key="log_context" value="$${ctx:log_topic:-security}" />
<KeyValuePair key="timestamp" value="$${date:yyyy-MM-dd'T'HH:mm:ss.SSSZ}" />
<KeyValuePair key="storage_id" value="$${ctx:storage_id}" />
<KeyValuePair key="storage_id" value="$${ctx:storage_id:-}" />
</JsonLayout>
</RollingFile >
<RollingFile name="Spring-Appender" fileName="${log-path}/spring.log"
Expand Down
15 changes: 15 additions & 0 deletions deploy/docker/cp-search-elk/pipelines/api_server.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,21 @@
]
}
},
{
"remove": {
"field": "storage_id",
"if": "ctx.storage_id == ''",
"ignore_missing": true,
"ignore_failure": true
}
},
{
"convert" : {
"field" : "storage_id",
"type": "long",
"ignore_missing": true
}
},
{
"remove": {
"field": "timestamp",
Expand Down

0 comments on commit 3e37755

Please sign in to comment.