[Beats] Hints autodiscovery support with Filestream input #35984
Description
Describe the enhancement:
The filestream input is the suggested input type for log processing with filebeat.
The hints autodiscovery is based on container input type (see code here) . So by default logs will be retrieved from the container using the container input.
So with this enhancement request we would like users to define hints based autodiscovery with filestream input type and to be able:
- To use the existing
co.elastic.logs/*
annotations in the hints annotations of the application pods and - The annotations configure the relevant parsers of the filestream input
Describe a specific use case for the enhancement or feature:
Filebeat configuration:
filebeat.autodiscover:
providers:
- type: kubernetes
node: ${NODE_NAME}
hints.enabled: true
hints.default_config:
type: filestream
prospector.scanner.symlinks: true
id: filestream-kubernetes-pod-${data.kubernetes.container.id}
take_over: true
paths:
- /var/log/containers/*-${data.kubernetes.container.id}.log
parsers:
- container: ~
See above that type: filestream
The user will define in the pod:
annotations:
co.elastic.logs/json.add_error_key: "true"
co.elastic.logs/json.expand_keys: "true"
co.elastic.logs/json.ignore_decoding_error: "true"
co.elastic.logs/json.keys_under_root: "true"
co.elastic.logs/json.message_key: "message"
And those will produce the following block:
parsers:
- ndjson:
ignore_decoding_error: "true"
expand_keys: "true"
keys_under_root: "true"
message_key: "message"
So overall configuration of filebeat should transform to:
filebeat.autodiscover:
providers:
- type: kubernetes
node: ${NODE_NAME}
hints.enabled: true
hints.default_config:
type: filestream
prospector.scanner.symlinks: true
id: filestream-kubernetes-pod-${data.kubernetes.container.id}
take_over: true
paths:
- /var/log/containers/*-${data.kubernetes.container.id}.log
parsers:
- container: ~
- ndjson:
ignore_decoding_error: "true"
expand_keys: "true"
keys_under_root: "true"
message_key: "message"
Same logic needs to be supported for rest of parsers
This was also previously discussed at #34354. Check also that one for additional context.