我正在使用 Splunk OTEL Collector Helm 图表将日志从我的 GKE Pod 发送到 Splunk Cloud Platform。我已将
UsesplunkIncludeAnnotation
设置为 true
以过滤来自特定 Pod 的日志。在我尝试过滤发送的日志之前,此设置工作正常。我将以下配置添加到我的 splunk
values.yaml:
config:
processors:
filter/ottl:
error_mode: ignore
logs:
log_record:
- 'IsMatch(body, "GET /status")'
- 'IsMatch(body, "GET /healthcheck")'
当我应用此配置时,指定的日志按预期被排除,但它没有过滤来自指定 Pod 的日志。我仍在接收来自所有 pod 的日志,并且注释未生效。此外,主机显示不正确并显示为“未知”。
我的问题是:
该问题似乎与服务管道中处理器的放置有关。
您可以通过以下方式解决这些问题:
filter/ottl 处理器需要正确放置在服务管道中才能有效应用日志排除。确保该处理器包含在管道配置中。
主机显示为“未知”的问题可以通过将 resourcedetection 处理器添加到管道中来解决。该处理器有助于检测资源相关属性并将其添加到日志中。
config:
processors:
filter/ottl:
logs:
log_record:
- 'IsMatch(body, "GET /status")'
- 'IsMatch(body, "GET /healthcheck")'
service:
pipelines:
logs:
processors:
- filter/ottl
- resourcedetection
- k8sattributes
- batch
- filter/logs
- resource/logs
此设置应按预期有效过滤日志,并根据注释包含正确的 Pod。