Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate events in logs-apm.error datastream when log sending is enabled on agents #13743

Open
lahsivjar opened this issue Jul 23, 2024 · 1 comment
Labels
bug operational Tasks to be picked up during support rotation

Comments

@lahsivjar
Copy link
Contributor

lahsivjar commented Jul 23, 2024

APM Server version (apm-server version): All versions supporting log ingestion

Description of the problem including expected versus actual behavior:
The current datastream routing code uses event.Type() which is inferred based on the below logic:

func (a *APMEvent) Type() APMEventType {
	switch {
	case a.Metricset != nil:
		return MetricEventType
	case a.Error != nil:
		return ErrorEventType
	case a.Log != nil || a.Event.GetKind() == "event":
		return LogEventType
	case a.Span.GetType() != "":
		return SpanEventType
	case a.Transaction.GetType() != "":
		return TransactionEventType
	}
	return UndefinedEventType
}

(ref)
A log event with stacktrace, error type, or error message, is parsed into the APMEvent#Error. Which would route them to error datastream (logs-apm.error.*).
OTOH, for an error event captured by the agent with error type, error message, and stacktrace as Exception#Stacktrace will also be parsed into APMEvent#Error.

Meaning both the above events would be treated as an error type rather than log type. This leads to the issue when an agent is configured to capture logs. In this case, both the error event and the log will be sent to APM-Server and would end up in the same datastream causing duplicate error events. In addition, the grouping key for these would be difference since the grouping key for an error event would used the parsed stack trace (ref).

Steps to reproduce:

Send an error event and a log event for the same error to APM-Server and observe both being indexed in the same, logs-apm.error* datastream.

Please include a minimal but complete recreation of the problem,

Provide logs (if relevant): N/A

@lahsivjar
Copy link
Contributor Author

One solution to this could be to ALWAYS route any explicit log events (with event root as log) to the log data-stream.

@simitt simitt added the bug label Jul 26, 2024
@simitt simitt added the operational Tasks to be picked up during support rotation label Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug operational Tasks to be picked up during support rotation
Projects
None yet
Development

No branches or pull requests

2 participants