You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Data prepper throws java.lang.IllegalStateException: Duplicate key xxx when ingest through log pipeline.
See the error below, due to open telemetry exporter exporting a duplicate ConnectionId key. Not sure this is expected behavior or not. Please help considering to fix this issue.
2023-12-29T07:28:02,516[pool-13-thread-1]ERRORorg.opensearch.dataprepper.plugins.source.otellogs.OTelLogsGrpcService-Failedtoparsetherequestresource_logs{resource{
...truncate...scope_logs{scope{name: "Microsoft.Extensions.Hosting.Internal.Host"}log_records{time_unix_nano: 1703834880595497100severity_number: SEVERITY_NUMBER_DEBUGseverity_text: "Debug"body{string_value: "Connection id \"{ConnectionId}\" sending FIN because: \"{Reason}\""}attributes{key: "ConnectionId"value{string_value: "0HN087UNTCNA9"}}attributes{key: "Reason"value{string_value: "The Socket transport\'s send loop completed gracefully."}}attributes{key: "ConnectionId"value{string_value: "0HN087UNTCNA9"}}observed_time_unix_nano: 1703834880595497100}}}java.lang.IllegalStateException: Duplicatekeylog.attributes.ConnectionId(attemptedmergingvalues0HN087UNTCNA9and0HN087UNTCNA9)atjava.base/java.util.stream.Collectors.duplicateKeyException(Collectors.java:135)~[?:?]atjava.base/java.util.stream.Collectors.lambda$uniqKeysMapAccumulator$1(Collectors.java:182)~[?:?]atjava.base/java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)~[?:?]atjava.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)~[?:?]atjava.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)~[?:?]atjava.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)~[?:?]atjava.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)~[?:?]atjava.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)~[?:?]atjava.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)~[?:?]atorg.opensearch.dataprepper.plugins.otel.codec.OTelProtoCodec.unpackKeyValueListLog(OTelProtoCodec.java:1094)~[otel-proto-common-2.6.1.jar:?]atorg.opensearch.dataprepper.plugins.otel.codec.OTelProtoCodec$OTelProtoDecoder.lambda$processLogsList$7(OTelProtoCodec.java:376)~[otel-proto-common-2.6.1.jar:?]
To Reproduce
Steps to reproduce the behavior:
I have pushed the sample repository, please visit here
Run docker-compose -f docker-compose.yml up -d
curl --location 'http://localhost:5000'
Wait a couple of seconds, then check data-prepper log. docker logs -f data-prepper
Expected behavior
Remove the duplicate key and ingest the log without issue.
Not sure whether this is a right place to fix or not ( forgive me if I'm wrong, I'm a .net developer - FYI) Code
protectedList<OpenTelemetryLog> processLogsList(finalList<LogRecord> logsList,
finalStringserviceName,
finalMap<String, Object> ils,
finalMap<String, Object> resourceAttributes,
finalStringschemaUrl) {
returnlogsList.stream()
.map(log -> JacksonOtelLog.builder()
.withTime(OTelProtoCodec.convertUnixNanosToISO8601(log.getTimeUnixNano()))
.withObservedTime(OTelProtoCodec.convertUnixNanosToISO8601(log.getObservedTimeUnixNano()))
.withServiceName(serviceName)
.withAttributes(OTelProtoCodec.mergeAllAttributes(
Arrays.asList(
// would be possible to de-duplicate log.getAttributesList() first ???, so that will solve the problem.OTelProtoCodec.unpackKeyValueListLog(log.getAttributesList()),
resourceAttributes,
ils
)
))
.withSchemaUrl(schemaUrl)
.withFlags(log.getFlags())
.withTraceId(OTelProtoCodec.convertByteStringToString(log.getTraceId()))
.withSpanId(OTelProtoCodec.convertByteStringToString(log.getSpanId()))
.withSeverityNumber(log.getSeverityNumberValue())
.withSeverityText(log.getSeverityText())
.withDroppedAttributesCount(log.getDroppedAttributesCount())
.withBody(OTelProtoCodec.convertAnyValue(log.getBody()))
.build())
.collect(Collectors.toList());
}
Screenshots
If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
OS: Debian
Version: 12
Additional context
N/A
The text was updated successfully, but these errors were encountered:
Hi @dlvenable
Yes, I use dotnet exporter, this is problematic with open-telemetry dotnet, but data-prepper should be agnostics from the exporter I think.
The merge mechanism should not be critical, duplicates have the same key/value anyway. I suggest we get the last value.
In C#, we can implement like this:
Describe the bug
Data prepper throws java.lang.IllegalStateException: Duplicate key xxx when ingest through log pipeline.
See the error below, due to open telemetry exporter exporting a duplicate ConnectionId key. Not sure this is expected behavior or not. Please help considering to fix this issue.
To Reproduce
Steps to reproduce the behavior:
docker-compose -f docker-compose.yml up -d
curl --location 'http://localhost:5000'
docker logs -f data-prepper
Expected behavior
Remove the duplicate key and ingest the log without issue.
Not sure whether this is a right place to fix or not ( forgive me if I'm wrong, I'm a .net developer - FYI)
Code
Screenshots
If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
Additional context
N/A
The text was updated successfully, but these errors were encountered: