Skip to content

Commit 62648a7

Browse files
author
Jeel Mehta
committed
Changing the filter pattern for validating logs
1 parent f5eddea commit 62648a7

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

validator/src/main/java/com/amazon/aoc/validators/CWLogValidator.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void validate() throws Exception {
6868
Map<String, Object> actualLog;
6969

7070
if (isOtlpSigV4Log(expectedAttributes)) {
71-
actualLog = this.getActualOtlpSigV4Log();
71+
actualLog = this.getActualOtlpSigV4Log(expectedAttributes);
7272
} else {
7373
String operation = (String) expectedAttributes.get("Operation");
7474
String remoteService = (String) expectedAttributes.get("RemoteService");
@@ -234,11 +234,14 @@ private Map<String, Object> getActualOtelSpanLog(String operation, String remote
234234
return JsonFlattener.flattenAsMap(retrievedLogs.get(0).getMessage());
235235
}
236236

237-
private Map<String, Object> getActualOtlpSigV4Log() throws Exception {
237+
private Map<String, Object> getActualOtlpSigV4Log(Map<String, Object> expectedAttributes) throws Exception {
238238
// Filter pattern to match OTLP SigV4 logs
239239
String filterPattern = String.format(
240-
"{ ($.resource.attributes.service.name = \"%s\") && $.body EXISTS && $.severityNumber EXISTS && $.severityText EXISTS }",
241-
context.getServiceName()
240+
"{ ($.attributes.otelServiceName = \"%s\") && ($.severityNumber = \"%s\") && ($.severityText = \"%s\") && ($.body = \"%s\") }",
241+
context.getServiceName(),
242+
expectedAttributes.get("severityNumber"),
243+
expectedAttributes.get("severityText"),
244+
expectedAttributes.get("body")
242245
);
243246
log.info("Filter Pattern for OTLP SigV4 Log Search: " + filterPattern);
244247

validator/src/main/resources/expected-data-template/python/ec2/adot-sigv4/logs/log.mustache

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,8 @@
1313
"severityText": "{{severityText}}",
1414
"body": "{{body}}",
1515
"traceId": "{{traceId}}",
16-
"spanId": "{{spanId}}"
16+
"spanId": "{{spanId}}",
17+
"attributes": {
18+
"otelServiceName": "{{serviceName}}"
19+
}
1720
}]

0 commit comments

Comments
 (0)