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

[dockerstatsreceiver] add new log receiver to ingest docker events #36284

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

spiffyy99
Copy link
Contributor

@spiffyy99 spiffyy99 commented Nov 8, 2024

Description

Adds a log receiver for dockerstatsreceiver to ingest docker events. Adheres to the otel events standards

Receiver calls client.Events to return channel and polls from channel. Retries connection to docker daemon upon error with exponential backoff by calling Events method repeatedly (per client spec)

Link to tracking issue

Fixes 29096

Testing

Unit testing, e2e (in progress/todo)

Documentation

Modified readme.md with new config fields, in development status for log receiver, and description of receiver behavior.

@github-actions github-actions bot requested a review from jamesmoessis November 8, 2024 22:45
@spiffyy99 spiffyy99 force-pushed the add-docker-stats-log-receiver branch 7 times, most recently from 8e96a6f to 735799c Compare November 14, 2024 04:57
@spiffyy99 spiffyy99 marked this pull request as ready for review November 14, 2024 04:57
@spiffyy99 spiffyy99 requested a review from a team as a code owner November 14, 2024 04:57
@spiffyy99 spiffyy99 requested a review from ChrsMark November 14, 2024 04:57
@spiffyy99
Copy link
Contributor Author

spiffyy99 commented Nov 14, 2024

Ready for review for the most part, just need to update integration tests.

@spiffyy99 spiffyy99 force-pushed the add-docker-stats-log-receiver branch 5 times, most recently from 4ec4ccf to 91c22b8 Compare November 14, 2024 12:40
@spiffyy99
Copy link
Contributor Author

@jamesmoessis could you take a look at this?

Copy link
Contributor

github-actions bot commented Dec 8, 2024

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Dec 8, 2024
@jamesmoessis
Copy link
Contributor

@spiffyy99 apologies for the delay, I will review this tomorrow.

@@ -35,9 +36,22 @@ func createDefaultConfig() component.Config {
Timeout: scs.Timeout,
},
MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(),
MinDockerRetryWait: time.Second,
MaxDockerRetryWait: 10 * time.Second,
Logs: EventsConfig{},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this collect events automatically? I think it should be off-by-default as to not affect existing deployments with the receiver running

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or will the log not be active unless they put it into a log pipeline... Good to know either way

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the latter, i'd assume. because pipelines are created in the config like this:

pipelines:
    logs:
      receivers: ...
      exporters: ...
      processors: ...

so there'd be no reason to create a logs receiver unless it was used in a pipeline, even if the config called for one.

@github-actions github-actions bot removed the Stale label Dec 10, 2024
Copy link
Contributor

@jamesmoessis jamesmoessis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks pretty good to me. Just some minor comments and questions.

Given I am not too familiar with logs in the Collector, would be nice to have a review from a maintainer that knows logs well.

receiver/dockerstatsreceiver/README.md Outdated Show resolved Hide resolved

- `endpoint` (default = `unix:///var/run/docker.sock`): Address to reach the desired Docker daemon.
- `excluded_images` (no default, all running containers monitored): A list of strings,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a scenario where you want to collect logs from one set of images, and metrics from another set? Currently it's set to both. I think, in this scenario you probably just create two different configs, but nevertheless thought I'd bring it up.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah what can be done in this case is creating a different receiver entirely. i'll mention this case in the documentation

receiver/dockerstatsreceiver/logs_receiver.go Outdated Show resolved Hide resolved
// event stream can be interrupted by async errors (connection or other).
// client caller must retry to restart processing. retry with backoff here
// except for context cancellation.
eventChan, errChan := d.client.Events(ctx, events.ListOptions{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the minimum Docker API version supported for these operations? If it is a higher version than otherwise documented in this receiver, it should be noted in the docs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not sure about the minimum for events, but 1.25 for sure supports events:

https://docs.docker.com/reference/api/engine/version/v1.25/#tag/System/operation/SystemVersion

as for versions before that, i feel like we should keep 1.25 as the minimum for both receivers because it's already kind of outdated.

}

func (r *logsReceiver) Shutdown(_ context.Context) error {
if r.cancel != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider a sync.WaitGroup to ensure the goroutine terminates synchronously with Shutdown()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

@spiffyy99 spiffyy99 force-pushed the add-docker-stats-log-receiver branch from 91c22b8 to 4308728 Compare December 13, 2024 20:44
@spiffyy99 spiffyy99 force-pushed the add-docker-stats-log-receiver branch from 4308728 to e2b2b87 Compare December 18, 2024 17:47
@spiffyy99
Copy link
Contributor Author

spiffyy99 commented Dec 18, 2024

updated integration tests and addressed all comments. might help to have a second reviewer as well, @ChrsMark could you take a look?

@spiffyy99 spiffyy99 force-pushed the add-docker-stats-log-receiver branch from e2b2b87 to d2661f6 Compare December 18, 2024 18:13
Copy link
Contributor

@jamesmoessis jamesmoessis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done! Thankyou for your contribution

@jamesmoessis
Copy link
Contributor

@spiffyy99 - also feel free to add yourself as a codeowner for this component, if you wish. Looking for someone to review logging contributions going forward

@spiffyy99
Copy link
Contributor Author

@spiffyy99 - also feel free to add yourself as a codeowner for this component, if you wish. Looking for someone to review logging contributions going forward

Sure, i can do that.

@spiffyy99 spiffyy99 force-pushed the add-docker-stats-log-receiver branch from d2661f6 to d041096 Compare December 19, 2024 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add docker event receiver
3 participants