-
Notifications
You must be signed in to change notification settings - Fork 149
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
Fix log collection with hints when missing container ports or annotations #2386
Conversation
Signed-off-by: ChrsMark <chrismarkou92@gmail.com>
This pull request does not have a backport label. Could you fix it @ChrsMark? 🙏
NOTE: |
Signed-off-by: ChrsMark <chrismarkou92@gmail.com>
🌐 Coverage report
|
I tried to test locally but seems that hints emmition is not working? ❯ ./elastic-agent inspect -v --variables --variables-wait 2s -c elastic-agent.yml
inputs: []
providers:
kubernetes:
hints:
enabled: true
kube_config: /Users/andreasgkizas/.kube/config
node: pas-control-plane ❯ cat elastic-agent.yml
providers:
kubernetes:
kube_config: /Users/andreasgkizas/.kube/config
node: "pas-control-plane"
hints.enabled: true
inputs:
- name: filestream-redis
type: filestream
use_output: default
streams:
- condition: ${kubernetes.hints.redis.log.enabled} == true or ${kubernetes.hints.redis.enabled} == true
data_stream:
dataset: redis.log
type: logs
exclude_files:
- .gz$
exclude_lines:
- ^\s+[\-`('.|_]
parsers:
- container:
format: auto
stream: ${kubernetes.hints.redis.log.stream|'all'}
paths:
- /var/log/containers/*${kubernetes.hints.container_id}.log
prospector:
scanner:
symlinks: true
tags:
- redis-log Also an observation: Is this accurate: |
Signed-off-by: ChrsMark <chrismarkou92@gmail.com>
Thanks @ChrsMark for the extra eyes and help to troubleshoot! I needed a bigger wait period New config_sample2.yaml : providers:
kubernetes:
kube_config: /Users/andreasgkizas/.kube/config
node: "pas-control-plane"
hints.enabled: true
inputs:
- name: filestream-generic
id: hints-container-logs-${kubernetes.hints.container_id}
type: filestream
use_output: default
streams:
- condition: ${kubernetes.hints.generic_logs.container_logs.enabled} == true
data_stream:
dataset: kubernetes.hints.container_logs
type: logs
exclude_files: [ ]
exclude_lines: [ ]
parsers:
- container:
format: auto
stream: ${kubernetes.hints.generic_logs.stream|'all'}
paths:
- /var/log/containers/*${kubernetes.hints.container_id}.log
prospector:
scanner:
symlinks: true
tags: [ ]
data_stream.namespace: default This way we get all the logs from cluster: |
What does this PR do?
This PR enhances hints mechanism for logging use cases by adding the following:
hints.default_container_logs: false
How to test this PR manaully
Multiple containers case
Define the following Agent config:
Run a target pod with hints annotations:
Execute the
inspect
command to produce to populate the inputs:./elastic-agent inspect -v --variables --variables-wait 2s
trueThe expected outcome will be 2 filestream inputs, one per container, ie:
Generic logs collection for all non annotated containers
Use the following agent config:
Execute the
inspect
command to populate the inputs:./elastic-agent inspect -v --variables --variables-wait 2s
trueThe expected outcome will be filestream inputs for all the discovered containers, one per container.
Uncomment the
hints.default_container_logs: false
and run again to see that no generic log inputs are populated.