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

Sampling of APM Log Messages in Kafka Provider #3431

Closed
peterfouquet0001 opened this issue Nov 20, 2023 · 8 comments
Closed

Sampling of APM Log Messages in Kafka Provider #3431

peterfouquet0001 opened this issue Nov 20, 2023 · 8 comments
Labels
agent-java community Issues and PRs created by the community triage

Comments

@peterfouquet0001
Copy link

Is your feature request related to a problem?

We are using the java apm agent 1.43.0.
The agent logs every kafka receive message event into the apm logfile and produces to many load on the apm server.
The setting ELASTIC_APM_TRANSACTION_SAMPLE_RATE reduce only the attributes in the log event, but not the count of the log events.
We need an additional property for sampling apm kafka events to log only a promille of the kafka events to apm.

Describe the solution you'd like

We need an additional property for sampling apm kafka events to log only a promille of the kafka events to apm.

For example
ELASTIC_APM_SAMPLE_RATE_TRANSACTION_TYPE_MESSAGING=0.001 and ELASTIC_APM_SAMPLE_RATE_TRANSACTION_TYPE_REQUEST=0.1

Describe alternatives you've considered

Additional context

The problem is the count of log entries for transaction type messaging

@github-actions github-actions bot added agent-java community Issues and PRs created by the community triage labels Nov 20, 2023
@jackshirazi
Copy link
Contributor

The agent logs every kafka receive message event into the apm logfile

Not by default - or if so it's a bug. Do you configure your app/agent to log these or are you saying the agent is logging all these by default?

@peterfouquet0001
Copy link
Author

We are using the apm defaults.

@JonasKunz
Copy link
Contributor

Are you referring to textual log messages being generated in the APM-agent logs?
Or are you actually referring to the number of transactions / spans being generated and sent to the APM-server?

@peterfouquet0001
Copy link
Author

Im referring to the number of textual log messages, because or application processed more than 1.000.000.000 Kafka Message per Day, an we will only log a small sample (e.g. only every thousandth event) in apm.

@JonasKunz
Copy link
Contributor

Unless you configured the apm agent log level to DEBUG or higher, there should be no log messages generated by the APM Agent. Can you show some example log messages?

@peterfouquet0001
Copy link
Author

Sorry,
i told about the log messages created by the apm agent for each processed kafka message, see attached examle
apm.txt

@JonasKunz
Copy link
Contributor

Okay, so you are seeing too many transactions. The problem is that your Kafka Transaction is not the root of the trace: It has a parent. ELASTIC_APM_TRANSACTION_SAMPLE_RATE only applies to root transactions and the resulting sampling rate is passed downstream via the kafka message.
You can do one of the following two things to fix this:

  • Configure ELASTIC_APM_TRANSACTION_SAMPLE_RATE on the service sending your Kafka messages (assuming that that is the root of the trace)
  • On your service receiving the messages set ELASTIC_APM_TRACE_CONTINUATION_STRATEGY to restart and configure ELASTIC_APM_TRANSACTION_SAMPLE_RATE. This will however cause distributed tracing to cease working.

@jackshirazi
Copy link
Contributor

I'm assuming this resolved the concern, feel free to comment further if needed but I'm closing this for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent-java community Issues and PRs created by the community triage
Projects
None yet
Development

No branches or pull requests

3 participants