从Log4J2中删除Dynatrace遥测

huangapple go评论72阅读模式
英文:

Remove Dynatrace Telemetry from Log4J2

问题

我们在 OpenShift 上运行一些 Java Spring Boot 应用程序,它们在 Docker 容器中运行。

我们遇到了一个问题,Dynatrace 开放遥测值被注入到我们日志的某些部分。

我们的 Java 项目中没有提到、引用或配置关于 Dynatrace 的任何信息,因此这完全是从 jar 外部注入的(?我真的不知道它是如何到达那里的),简而言之,在记录在 OpenShift 控制台的消息以及发送到 HTTP appender(因为 http appender 和 console appender 使用相同的 JSON Layout)时,它被 dynatrace 参数污染。

我能够发现这仅发生在 JSON Layout 成员使用模式解析器的情况下,但无论模式是否调用上下文或仅使用静态值,它仍然会被插入。

JSON Layout 中使用模式的两个成员,可以看到它们非常不同,nanoSecond 使用静态常数 0

"nanoOfSecond": {
	"$resolver": "pattern",
	"pattern": "0",
	"stackTraceEnabled": false 
},
"dumpanalysis": {
	"$resolver": "pattern",
	"pattern": "%replace{%throwable{separator(|)}}{\t}{ }",
	"stackTraceEnabled": false
}

在 Openshift 日志中生成的行,并尝试发送到 HTTP appender

"nanoOfSecond": "0 {dt.trace_id=692ebfa9aa8bda8eaceb24d681fe73e0, dt.span_id=007beacb18281124, dt.trace_sampled=true}"

"dumpanalysis": " {dt.trace_id=692ebfa9aa8bda8eaceb24d681fe73e0, dt.span_id=007beacb18281124, dt.trace_sampled=true}"

我尝试更改模式以使用正则表达式替换 dt 成员,但显然这并没有起作用,因为这也存在于是一个静态常数的 nanoSecond 中。这个值是在某个时候(无论那个时候是什么)之后被提供的。

我完全不知所措,非常感谢任何帮助。

英文:

We have some java springboot applications running on docker containers in OpenShift.

We are running into an issue where Dynatrace open telemetry values are being injected into some parts of our logs.

Our Java projects have no mention or reference or configuration regarding Dynatrace, so this is injected completely from outside the jar(?, I honestly have no idea how it gets there), but long story short, when the message that is logged in the OpenShift console, and that is sent on an HTTP appender (since both the http appender and the console appender use the same JSON Layout) it is polluted with dynatrace parameters.

I was able to figure out that this only happens on the JSON Layout members that use a pattern resolver, but regardless if the pattern is calling the context or just using a static value, it still gets inserted.

Two of the members in the JSON Layout that use pattern, you can see they are very different, the nanoSecond using a static constant 0

"nanoOfSecond": {
			"$resolver": "pattern",
			"pattern": "0",
			"stackTraceEnabled": false 
		},
"dumpanalysis": {
		"$resolver": "pattern",
		"pattern": "%replace{%throwable{separator(|)}}{\t}{ }",
		"stackTraceEnabled": false
	}

Resulting lines spit out on the Openshift log and attempted to be sent on the HTTP appender

"nanoOfSecond": "0 {dt.trace_id=692ebfa9aa8bda8eaceb24d681fe73e0, dt.span_id=007beacb18281124, dt.trace_sampled=true}"

"dumpanalysis": " {dt.trace_id=692ebfa9aa8bda8eaceb24d681fe73e0, dt.span_id=007beacb18281124, dt.trace_sampled=true}"

I've tried changing the pattern to replace the dt members with regex but that obviously didn't work, since this is also present on the nanoSecond that is a static constant. This value is being fed after the fact, at some point (w/e that point is)

I am at a complete loss here, any help is deeply appreciated.

答案1

得分: 1

如果在主机上安装了Dynatrace OneAgent,则会自动将其注入到在该机器上启动的进程中。

有全局和进程级别的自动注入调整选项,还有配置特性级别的选项,因此您可以继续使用Dynatrace,但尝试减少Log4j中HTTP通信的影响。

有关可用配置设置的信息,请参阅Dynatrace文档

英文:

If the Dynatrace OneAgent is installed on a Host, it is automatically injected into processes started on that machine.

There are options to adjust this auto-instrumentation both globally and on process-level and also options to configure instrumentation on a feature-level so you can keep using Dynatrace but try to remove the impact on the HTTP-communication in Log4j.

See the Dynatrace Documentation for information available configuration settings.

答案2

得分: 1

这不应该在没有进一步咨询Dynatrace用户的情况下禁用,因为他们可能依赖于跟踪和日志之间的关联。它可以用于问题诊断和异常检测。你可能没有参与组织的可观测性和监控部分。

然而,在Dynatrace UI中可以进行如下操作:设置 > 监控 > 监控概览,然后在进程组选项卡中找到相关的Java Spring进程名称。单击铅笔图标以编辑该进程组的设置。

OneAgent功能菜单中,有一个按钮:"添加覆盖"

您需要为日志丰富功能添加一个新的覆盖,并将开关设为禁用(切换关闭)。

保存更改。

这可能需要重新启动/重新部署应用程序容器才能生效。

英文:

This shouldn't really be disabled without further consulting with the Dynatrace users, since they may be dependent upon the stitching between traces and logs. It could be used for problem diagnostics and anomaly detection. Since you don't know how your agent got there (it automatically injects from the host, by the way), tells me you might not be involved in the observability and monitoring part of your organisation.

However, within the Dynatrace UI it's possible to, go to: Settings > Monitoring > Monitoring Overview then find the related Java Spring process name within the process group tab. Click the pencil to edit the settings for that process group.

On the menu for OneAgent features, there is a button: "Add override".

You will want to add a new override for the log enrichment feature(s) and set the switch to disabled (toggle off).

Save changes.

This probably requires restart / redeploy of the application container to take effect.

Screenshot showing Java log enrichment settings

答案3

得分: 0

发布答案是因为这解决了问题,但The_AM和Centic的答案也是正确的,但我没有参与监控过程,正如The_AM建议的那样。

基本上,Dynatrace的遥测在将日志主体发送到日志服务时导致我的服务失败,因为控制器试图将String映射为Long。
我所做的是向我的模型添加一个自定义反序列化程序,它会在设置属性之前清除Dynatrace数据,因此根本不需要更改字段类型。

是的,我理解这可能会删除Dynatrace分析可能需要的数据,但将其强加于服务到这个程度,甚至到破坏服务本身的程度,我认为是错误的,即:他们搞砸了,所以他们应该修复它,如果他们不修复,我会自己修复,如果他们不喜欢我的修复,他们应该修复它。

英文:

Posting an answer here as this is what solved the problem, but both The_AM and Centic's answers are also correct, but I am not involved in the monitoring process as The_AM suggested.

Basically, the dynatrace telemetry was making my service fail when the log body was sent to the logging service as the controller was trying to map a String into a Long.
What I did was adding a custom deserialzier to my model that would scrub the dynatrace data off before setting to the property, thus not needing to change the field type at all.

Yes, I understand this might remove data that the dynatrace analysis might need, but forcing it on a service to this level, to a point where it breaks the service itself seems wrong imo, aka: They broke it so they should fix it, if they don't I will fix it myself, if they don't like my fix, they should fix it.

huangapple
  • 本文由 发表于 2023年4月20日 04:50:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/76058710.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定