You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Filebeat deployed in a Kubernetes cluster a user can select autodiscovery with kubernetes provider instead of using filebeat.inputs. This can be done by commenting the filebeat.inputs block and uncommenting the filebeat.autodiscover one as described in
# To enable hints based autodiscover, remove `filebeat.inputs` configuration and uncomment this:
.
If hints are enabled, in the hints.default_config: block the user specifies which input will be used for each discovered resource and can additionally set processors, parsers and paths. As an example:
The expected behaviour would be that for Redis discovered pod the container input will be used. Its configuration would include both the processors (add_tags from default_config and add_fields from hints). It should look like this (for processors alone):
{"log.level":"error","@timestamp":"2023-10-13T14:01:46.466Z","log.logger":"autodiscover.cfgfile","log.origin":{"file.name":"cfgfile/list.go","file.line":138},"message":"Error creating runner from config: each processor must have exactly one action, but found 2 actions (add_fields,add_tags)","service.name":"filebeat","ecs.version":"1.6.0"}
Both processors don't work and Redis logs are not collected.
Reason
The reason for that error is that the merged processors configuration looks like this:
add_tags and add_fields are grouped together under the same processor index. add_fields is not appended even though the processors is a list. This happens in this code line where the hints config is merged to default_config. The Merge method used by default does not append elements to lists. This is explained in this issue
Solution
Instead of the merge method, MergeWithOpts should be used with the option AppendValues. config.MergeWithOpts(tempCfg, ucfg.AppendValues).
That way processors or parsers or paths found in the hints will be appended in the existing ones from default_config.
This has been tested to work properly.
The text was updated successfully, but these errors were encountered:
Description
In Filebeat deployed in a Kubernetes cluster a user can select autodiscovery with kubernetes provider instead of using
filebeat.inputs
. This can be done by commenting thefilebeat.inputs
block and uncommenting thefilebeat.autodiscover
one as described inbeats/deploy/kubernetes/filebeat-kubernetes.yaml
Line 125 in 8a70712
If hints are enabled, in the
hints.default_config:
block the user specifies which input will be used for each discovered resource and can additionally set processors, parsers and paths. As an example:User can then deploy a pod and annotate it with hints to include additional processors like this :
Expected behaviour
The expected behaviour would be that for Redis discovered pod the container input will be used. Its configuration would include both the processors (
add_tags
from default_config andadd_fields
from hints). It should look like this (for processors alone):Result
Instead filebeat logs an error:
Both processors don't work and Redis logs are not collected.
Reason
The reason for that error is that the merged processors configuration looks like this:
add_tags
andadd_fields
are grouped together under the same processor index.add_fields
is not appended even though the processors is a list. This happens in this code line where the hints config is merged to default_config. The Merge method used by default does not append elements to lists. This is explained in this issueSolution
Instead of the
merge
method,MergeWithOpts
should be used with the optionAppendValues
.config.MergeWithOpts(tempCfg, ucfg.AppendValues)
.That way processors or parsers or paths found in the hints will be appended in the existing ones from default_config.
This has been tested to work properly.
The text was updated successfully, but these errors were encountered: