Add autodetection mode for add_docker_metadata#13374
Add autodetection mode for add_docker_metadata#13374ChrsMark merged 6 commits intoelastic:masterfrom
Conversation
93b280c to
e95b724
Compare
52ca9f6 to
fc97617
Compare
|
@jsoriano thanks for reviewing! Your suggestion have been addressed, however the checks are failing due to the addition in |
|
099ff3a to
ca1d202
Compare
jsoriano
left a comment
There was a problem hiding this comment.
LGTM, I have added a couple of extra suggestions, let me know what you think.
There was a problem hiding this comment.
Log this error at debug level, and with the error too?
| logp.Info(errorMsg) | |
| logp.Debugf("%s: %v", errorMsg, err) |
And same thing for the other error some lines below.
6314ecf to
9a36f81
Compare
9a36f81 to
5434efa
Compare
Signed-off-by: chrismark <chrismarkou92@gmail.com>
Signed-off-by: chrismark <chrismarkou92@gmail.com>
Signed-off-by: chrismark <chrismarkou92@gmail.com>
Signed-off-by: chrismark <chrismarkou92@gmail.com>
5434efa to
6f679bb
Compare
6f679bb to
ecb905d
Compare
Signed-off-by: chrismark <chrismarkou92@gmail.com>
ecb905d to
abfc865
Compare
|
Changed the implementation a little bit so as to perform the connectivity check for Docker with the proper configuration. |
jsoriano
left a comment
There was a problem hiding this comment.
Ok, I think we can go on with this 👍 I have added some comments about some minor details.
| dockerAvailable = true | ||
| logp.Debug("add_docker_metadata", "%v: docker environment detected", processorName) | ||
| if err = watcher.Start(); err != nil { | ||
| return nil, err |
There was a problem hiding this comment.
You can use errors.Wrap to give a bit more of context here:
| return nil, err | |
| return nil, errors.Wrap(err, "failed to start watcher") |
| assert.NoError(t, err, "processing an event") | ||
|
|
||
| assert.Equal(t, common.MapStr{}, result.Fields) | ||
| } |
There was a problem hiding this comment.
Thanks for adding a test for this
| return nil, err | ||
| } | ||
|
|
||
| // extra check to confirm that Docker is available |
There was a problem hiding this comment.
Nit.
| // extra check to confirm that Docker is available | |
| // Extra check to confirm that Docker is available |
|
|
||
| import ( | ||
| "fmt" | ||
|
|
There was a problem hiding this comment.
Please remove this extra new line.
| var err error | ||
| if !d.dockerAvailable { | ||
| return event, nil | ||
| } |
There was a problem hiding this comment.
Nit. You could move this code to the very end of the function, before these declarations.
| - add_host_metadata is no GA. {pull}13148[13148] | ||
| - Add `registered_domain` processor for deriving the registered domain from a given FQDN. {pull}13326[13326] | ||
| - Add support for RFC3339 time zone offsets in JSON output. {pull}13227[13227] | ||
| - Add autodetection mode for add_docker_metadata {pull}13374[13374] |
There was a problem hiding this comment.
Maybe we should mention something about enabling it by default.
| - Add autodetection mode for add_docker_metadata {pull}13374[13374] | |
| - Add autodetection mode for add_docker_metadata and enable it by default in included configuration files {pull}13374[13374] |
| _, err = client.Info(context.Background()) | ||
| if err != nil { | ||
| return nil, err | ||
| } |
There was a problem hiding this comment.
I wonder if this can affect other users of NewWatcher, it seems safe though.
There was a problem hiding this comment.
Yes it could affect others (AutodiscoverBuilder) in case of a connectivity error, but it wont be a problem I think, since an error will be returned for a case that is indeed problematic.
Signed-off-by: chrismark <chrismarkou92@gmail.com>
The PR #13374 adds `add_docker_metadata` for all Beats. However, this results in the following error in Functionbeat when deployed to AWS: ``` Exiting: error initializing processors: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? ``` Thus, the function fails to start and process messages. This PR removes the processor from the configuration of Functionbeat. So the function is able to start with the default processor configuration.
…4424) The PR elastic#13374 adds `add_docker_metadata` for all Beats. However, this results in the following error in Functionbeat when deployed to AWS: ``` Exiting: error initializing processors: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? ``` Thus, the function fails to start and process messages. This PR removes the processor from the configuration of Functionbeat. So the function is able to start with the default processor configuration. (cherry picked from commit d9a4c9c)
…4424) The PR elastic#13374 adds `add_docker_metadata` for all Beats. However, this results in the following error in Functionbeat when deployed to AWS: ``` Exiting: error initializing processors: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? ``` Thus, the function fails to start and process messages. This PR removes the processor from the configuration of Functionbeat. So the function is able to start with the default processor configuration. (cherry picked from commit d9a4c9c)
…14480) The PR #13374 adds `add_docker_metadata` for all Beats. However, this results in the following error in Functionbeat when deployed to AWS: ``` Exiting: error initializing processors: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? ``` Thus, the function fails to start and process messages. This PR removes the processor from the configuration of Functionbeat. So the function is able to start with the default processor configuration. (cherry picked from commit d9a4c9c)
…14479) The PR #13374 adds `add_docker_metadata` for all Beats. However, this results in the following error in Functionbeat when deployed to AWS: ``` Exiting: error initializing processors: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? ``` Thus, the function fails to start and process messages. This PR removes the processor from the configuration of Functionbeat. So the function is able to start with the default processor configuration. (cherry picked from commit d9a4c9c)
…4424) (elastic#14480) The PR elastic#13374 adds `add_docker_metadata` for all Beats. However, this results in the following error in Functionbeat when deployed to AWS: ``` Exiting: error initializing processors: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? ``` Thus, the function fails to start and process messages. This PR removes the processor from the configuration of Functionbeat. So the function is able to start with the default processor configuration. (cherry picked from commit c25f71a)
This PR is a proposal for enabling autodetection mode for
add_docker_metadata.Currently we configure
add_cloud_metadataandadd_host_metadataby default in all Beats.add_cloud_metadatadoes autodetection, and it will only enrich events if the beat is running on a known public cloud.It would be useful to have the same for Docker (and Kubernetes), so if Beats is started in a scenario where Docker is available, it automatically enables metadata for it. If Docker is not present nothing will happen.
In this PR only the Docker part is covered. After we conclude to a final approach, a follow-up PR will come for the Kubernetes part.
How to test it
a. Run metricbeat or filebeat in an environement where Docker is present.
b. Verify that processor is being automatically enabled.
a. Run metricbeat or filebeat in an environement where Docker is not present.
b. Verify that processor is not being automatically enabled.