Container is isolated, which means i do not have enough privilege to access other container. What i did is to mount log files to elastic agent, but it does not solve metricbeat problem that can not access system stats.
This is my simple compose file, agent
can collect postgres
log but it can not retrieve postgres
container system stats (e.g. cpu, network)
agent:
image: docker.elastic.co/beats/elastic-agent:${STACK_VERSION}
hostname: agent-service-01
volumes:
- ...
- logs:/var/logs:ro # collect logs
environment:
- FLEET_ENROLLMENT_TOKEN=<TOKEN>
- FLEET_ENROLL=1
- FLEET_URL=https://efleet:8220
- FLEET_CA=/usr/share/elastic-agent/certs/ca/ca.crt
pgsql:
image: postgres:14.7
hostname: pgsql-01
command: postgres -c config_file=/usr/share/postgresql/postgresql.conf
volumes:
- ./elastic/logs/pgsql/:/var/log/postgresql/
- ./elastic/config/postgresql.conf:/usr/share/postgresql/postgresql.conf
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=pg
Im trying to avoid building dockerfile(docker image), so i wonder how let elastic agent can access system stats. Accessing Host Machine is a alternate solution since a host machine only install one application.