[AD] Not discovering new containers with container_exclude_metrics: image:.*
Describe what happened: I am trying to exclude metric collection and ONLY collect logs for my containers. If I start the agent, it tails logs from sibling containers fine, however if they change status (e.g. existing containers stopped, or new containers started), the datadog-agent does not notice this.
Describe what you expected: I expect that the agent would still discover containers starting up or spinning down, but not report any metric/event collection to Datadog (I just want logs).
Steps to reproduce the issue:
Using config:
site: datadoghq.com
dd_url: https://app.datadoghq.com
cloud_provider_metadata:
- "aws"
collect_ec2_tags: true
logs_enabled: true
listeners:
- name: docker
container_exclude_metrics:
- image:.*
apm_config:
enabled: false
process_config:
enabled: "disabled"
use_dogstatsd: false
autoconfig_exclude_features:
- cloudfoundry
- cri
- ecsfargate
- eksfargate
- kubernetes
- orchestratorexplorer
With log config at /etc/datadog-agent/conf.d/logging.d/conf.yaml
logs:
- type: file
path: "/var/log/host/messages"
source: "custom"
service: "messages"
- type: file
path: "/var/log/host/secure"
source: "custom"
service: "secure"
- type: file
path: "/var/log/host/audit/audit.log"
source: "custom"
service: "audit"
- type: file
path: "/var/log/datadog/*.log"
source: "custom"
service: "datadog"
Start the agent on a host with containers running. --> See that logs are ingested into Datadog correctly
Start a new container --> See that logs for the new container are NOT ingested
Stop an existing container a new container
Run agent configcheck
--> See that stopped container still appears in the autodiscovery list, and that the new container does not
Additional environment details (Operating System, Cloud provider, etc): Using datadog/agent 7.30.0
Deployed to ECS. Relevant task definition json:
"containerDefinitions": [
{
"name": "datadog-agent",
"essential": true,
"mountPoints": [
{
"readOnly": true,
"containerPath": "/var/run/docker.sock",
"sourceVolume": "docker_sock"
},
{
"readOnly": true,
"containerPath": "/host/sys/fs/cgroup",
"sourceVolume": "cgroup"
},
{
"readOnly": true,
"containerPath": "/host/proc",
"sourceVolume": "proc"
},
{
"readOnly": true,
"containerPath": "/var/lib/docker/containers",
"sourceVolume": "containers_root"
},
{
"readOnly": false,
"containerPath": "/opt/datadog-agent/run",
"sourceVolume": "pointdir"
},
{
"readOnly": true,
"containerPath": "/var/log/host",
"sourceVolume": "logs"
}
],
"healthCheck": {
"retries": 3,
"command": [
"CMD-SHELL",
"agent health"
],
"timeout": 5,
"interval": 30,
"startPeriod": 15
}
}
],
"compatibilities": [
"EXTERNAL",
"EC2"
],
"volumes": [
{
"name": "cgroup",
"host": {
"sourcePath": "/sys/fs/cgroup/"
}
},
{
"name": "pointdir",
"host": {
"sourcePath": "/opt/datadog-agent/run"
}
},
{
"name": "containers_root",
"host": {
"sourcePath": "/var/lib/docker/containers"
}
},
{
"name": "proc",
"host": {
"sourcePath": "/proc/"
}
},
{
"name": "docker_sock",
"host": {
"sourcePath": "/var/run/docker.sock"
}
},
{
"name": "logs",
"host": {
"sourcePath": "/var/log/"
}
}
]
}
Hey @ryzr
Thanks for opening an issue on the datadog repository. Right off the bat, I don't see why new containers wouldn't detected by the agent.
One thing though: we advise to use env vars rather than a customer datadog.yaml to configure the containerized agent. I don't see how you use the aforementioned config in your task definition. Do you bake it in a custom image?
Do you see the same behavior without the container_exclude_metrics parameter? I personally don't think it would cause this issue.
Would you be able to open a ticket with our support team by emailing [email protected]? This way our Support team will be able to ask you more details about the issue and investigate it further.
Thanks!
Simon
Thanks for the reply @Simwar :-)
I don't see how you use the aforementioned config in your task definition. Do you bake it in a custom image?
Correct; currently we just wrap the datadog/agent image:
FROM datadog/agent
COPY ./datadog.yaml /etc/datadog-agent/datadog.yaml
COPY ./logging.yaml /etc/datadog-agent/conf.d/logging.d/conf.yaml
We did this as I wasn't sure if there was another way to add file logging config (logging files form the container host).
Do you see the same behavior without the container_exclude_metrics parameter?
After removing the container_exclude_metrics parameter, new containers are detected as expected. I haven't tried toggling any of the other options though - I had a surprise bill already, and don't want to unintentionally enabling anything expensive again :-P
Would you be able to open a ticket with our support team by emailing [email protected]?
No worries, I'll email them now.
Thanks!
happens for us as well. no new containers get logs forwarded to DD
This issue has been automatically marked as stale because it has not had activity in the past 15 days.
It will be closed in 30 days if no further activity occurs. If this issue is still relevant, adding a comment will keep it open. Also, you can always reopen the issue if you missed the window.
Thank you for your contributions!
Hi all,
I am going to mark this issue as closed. Testing out with any modern version of the Agent using the DD_CONTAINER_EXCLUDE_METRICS configuration option results in only metric related telemetry being excluded from collection. Logging should be unaffected by this.
If you are still experiencing any issues with this, please open a support ticket in our helpdesk system (no login required). Thank you all!
– The Datadog Agent Team