-
Notifications
You must be signed in to change notification settings - Fork 483
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
Use container parser of stanza for logs collection #1195
Use container parser of stanza for logs collection #1195
Conversation
3898148
to
b83997a
Compare
Tested e2e as well on 2024-05-22T09:35:07.700Z info LogsExporter {"kind": "exporter", "data_type": "logs", "name": "debug", "resource logs": 1, "log records": 2}
2024-05-22T09:35:07.700Z info ResourceLog #0
Resource SchemaURL:
ScopeLogs #0
ScopeLogs SchemaURL:
InstrumentationScope
LogRecord #0
ObservedTimestamp: 2024-05-22 09:35:07.572874147 +0000 UTC
Timestamp: 2024-05-22 09:35:07.383200464 +0000 UTC
SeverityText:
SeverityNumber: Unspecified(0)
Body: Str(otel logs at 09:35:07)
Attributes:
-> log.file.path: Str(/var/log/pods/default_daemonset-logs-kk9m8_d5f6af9d-6ff6-4ba4-a8bb-dab9fea6838c/busybox/0.log)
-> k8s.container.name: Str(busybox)
-> k8s.namespace.name: Str(default)
-> k8s.pod.name: Str(daemonset-logs-kk9m8)
-> k8s.container.restart_count: Str(0)
-> log.iostream: Str(stdout)
-> logtag: Str(F)
-> k8s.pod.uid: Str(d5f6af9d-6ff6-4ba4-a8bb-dab9fea6838c)
-> time: Str(2024-05-22T09:35:07.383200464Z)
Trace ID:
Span ID:
Flags: 0
LogRecord #1
ObservedTimestamp: 2024-05-22 09:35:07.572974215 +0000 UTC
Timestamp: 2024-05-22 09:35:07.485134813 +0000 UTC
SeverityText:
SeverityNumber: Unspecified(0)
Body: Str(otel logs at 09:35:07)
Attributes:
-> k8s.pod.name: Str(daemonset-logs-kk9m8)
-> k8s.pod.uid: Str(d5f6af9d-6ff6-4ba4-a8bb-dab9fea6838c)
-> log.file.path: Str(/var/log/pods/default_daemonset-logs-kk9m8_d5f6af9d-6ff6-4ba4-a8bb-dab9fea6838c/busybox/0.log)
-> time: Str(2024-05-22T09:35:07.485134813Z)
-> log.iostream: Str(stdout)
-> logtag: Str(F)
-> k8s.namespace.name: Str(default)
-> k8s.container.restart_count: Str(0)
-> k8s.container.name: Str(busybox)
Trace ID:
Span ID:
Flags: 0
{"kind": "exporter", "data_type": "logs", "name": "debug"}
2024-05-22T09:35:07.901Z info ResourceLog #0
Resource SchemaURL:
ScopeLogs #0
ScopeLogs SchemaURL:
InstrumentationScope
LogRecord #0
ObservedTimestamp: 2024-05-22 09:35:07.772023047 +0000 UTC
Timestamp: 2024-05-22 09:35:07.587542234 +0000 UTC
SeverityText:
SeverityNumber: Unspecified(0)
Body: Str(otel logs at 09:35:07)
Attributes:
-> k8s.pod.name: Str(daemonset-logs-kk9m8)
-> k8s.container.restart_count: Str(0)
-> k8s.pod.uid: Str(d5f6af9d-6ff6-4ba4-a8bb-dab9fea6838c)
-> k8s.container.name: Str(busybox)
-> log.file.path: Str(/var/log/pods/default_daemonset-logs-kk9m8_d5f6af9d-6ff6-4ba4-a8bb-dab9fea6838c/busybox/0.log)
-> log.iostream: Str(stdout)
-> time: Str(2024-05-22T09:35:07.587542234Z)
-> k8s.namespace.name: Str(default)
-> logtag: Str(F)
Trace ID:
Span ID:
Flags: 0
LogRecord #1
ObservedTimestamp: 2024-05-22 09:35:07.772149911 +0000 UTC
Timestamp: 2024-05-22 09:35:07.689592419 +0000 UTC
SeverityText:
SeverityNumber: Unspecified(0)
Body: Str(otel logs at 09:35:07)
Attributes:
-> k8s.pod.uid: Str(d5f6af9d-6ff6-4ba4-a8bb-dab9fea6838c)
-> k8s.container.name: Str(busybox)
-> k8s.namespace.name: Str(default)
-> k8s.pod.name: Str(daemonset-logs-kk9m8)
-> time: Str(2024-05-22T09:35:07.689592419Z)
-> log.iostream: Str(stdout)
-> logtag: Str(F)
-> log.file.path: Str(/var/log/pods/default_daemonset-logs-kk9m8_d5f6af9d-6ff6-4ba4-a8bb-dab9fea6838c/busybox/0.log)
-> k8s.container.restart_count: Str(0)
Trace ID:
Span ID:
Flags: 0 |
) **Description:** <Describe what has changed.> <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> The [logsCollection](https://github.com/open-telemetry/opentelemetry-helm-charts/blob/ef0e1ac4f645cdbb9bd0108c76b1ed69e418430c/charts/opentelemetry-collector/values.yaml#L29C3-L37) Helm preset provides the option to set the `maxRecombineLogSize`. The `container` parser does not expose this option but rather sets it to `102400` by default internally. This PR is to make this option configurable so that the parser can be used in the [Helm preset seamlessly](open-telemetry/opentelemetry-helm-charts#1195). **Link to tracking Issue:** <Issue number if applicable> **Testing:** <Describe what testing was performed and which tests were added.> Added. **Documentation:** <Describe the documentation added.> Updated. Signed-off-by: ChrsMark <chrismarkou92@gmail.com>
This should not get merged until the |
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
/label -Stale |
@ChrsMark |
There was an additional fix for the parser that did not make it to I would suggest we wait for it, before doing the switch. |
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
Not stale. |
Signed-off-by: ChrsMark <chrismarkou92@gmail.com>
6542e5e
to
8ae4beb
Compare
@TylerHelmuth finally the fixes are in. This one should be ready for a review now. Test the produced configmap
receivers:
filelog:
exclude:
- /var/log/pods/default_daemonset-opentelemetry-collector*_*/opentelemetry-collector/*.log
include:
- /var/log/pods/*/*/*.log
include_file_name: false
include_file_path: true
operators:
- id: container-parser
max_log_size: 102400
type: container
retry_on_failure:
enabled: true
start_at: end Verify the produced log records
2024-06-25T08:15:12.981Z info ResourceLog #0
Resource SchemaURL:
Resource attributes:
-> k8s.namespace.name: Str(default)
-> k8s.pod.name: Str(daemonset-logs-8w7rm)
-> k8s.container.restart_count: Str(0)
-> k8s.pod.uid: Str(539b21bf-0b23-4929-ad61-a5c76820b309)
-> k8s.container.name: Str(busybox)
ScopeLogs #0
ScopeLogs SchemaURL:
InstrumentationScope
LogRecord #0
ObservedTimestamp: 2024-06-25 08:15:12.739110323 +0000 UTC
Timestamp: 2024-06-25 08:15:12.606659689 +0000 UTC
SeverityText:
SeverityNumber: Unspecified(0)
Body: Str(otel logs at 08:15:12)
Attributes:
-> logtag: Str(F)
-> log.file.path: Str(/var/log/pods/default_daemonset-logs-8w7rm_539b21bf-0b23-4929-ad61-a5c76820b309/busybox/0.log)
-> time: Str(2024-06-25T08:15:12.606659689Z)
-> log.iostream: Str(stdout)
Trace ID:
Span ID:
Flags: 0
LogRecord #1
ObservedTimestamp: 2024-06-25 08:15:12.739202433 +0000 UTC
Timestamp: 2024-06-25 08:15:12.707975372 +0000 UTC
SeverityText:
SeverityNumber: Unspecified(0)
Body: Str(otel logs at 08:15:12)
Attributes:
-> log.file.path: Str(/var/log/pods/default_daemonset-logs-8w7rm_539b21bf-0b23-4929-ad61-a5c76820b309/busybox/0.log)
-> time: Str(2024-06-25T08:15:12.707975372Z)
-> log.iostream: Str(stdout)
-> logtag: Str(F)
Trace ID:
Span ID:
Flags: 0
{"kind": "exporter", "data_type": "logs", "name": "debug"} |
- type: container | ||
id: container-parser |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ChrsMark @djaglowski thanks for making this parser, its amazing.
Signed-off-by: ChrsMark <chrismarkou92@gmail.com>
Fixes #1188.
This is a draft until the
v0.102.0
version of Collector is released, which will include the newmax_log_size
setting of the parser.Testing notes
helm install daemonset ./opentelemetry-collector --set presets.logsCollection.enabled=true --set image.repository="otel/opentelemetry-collector-k8s" --set command.name="otelcol-k8s" --set mode=daemonset
k get cm daemonset-opentelemetry-collector-agent -o jsonpath='{.data.relay}
: