configure datadog logs with docker labels
this part is not relevant anymore:
I upgraded to datadog agent 6, in order to give a try to the datadog logs beta and since then I’m not able to use docker labels to configure the agent:
I used to have this config in docker-compose.yml:
db:
image: postgres:10
volumes:
- db:/var/lib/postgresql/data:rw
labels:
com.datadoghq.ad.check_names: '["postgres"]'
com.datadoghq.ad.init_configs: '[{}]'
com.datadoghq.ad.instances: '[{"host": "ws_db", "port": 5432, "username": "$DATADOG_POSTGRES_USER", "password": "$DATADOG_POSTGRES_PASSWORD", "tags": ["app:ws"]}]'
deploy:
replicas: 1
placement:
constraints: [node.role == manager]
networks:
- datadog
- default
but this does not work anymore. I guess this is a feature not yet ported to this agent but can anyone confirm this ? or has the configuration format change ?
bonus:
this part is still relevant:
should that kind of configuration work for datadog logs ? (once implemented)
db:
image: postgres:10
environment:
POSTGRES_PASSWORD: docker
POSTGRES_USER: docker
volumes:
- db:/var/lib/postgresql/data:rw
- logs:/logs:rw
labels:
com.datadoghq.ad.check_names: '["postgres"]'
com.datadoghq.ad.init_configs: '[{}]'
com.datadoghq.ad.instances: '[{"host": "ws_db", "port": 5432, "username": "$DATADOG_POSTGRES_USER", "password": "$DATADOG_POSTGRES_PASSWORD", "tags": ["app:ws"]}]'
com.datadoghq.ad.logs: '{"type": "file", "path": "/logs/beesquad/*-ws.db.log", "tags": ["app:ws"], "source": "postgresql", "service": "ws", "sourcecategory": "database", "log_processing_rules": {"type": "multi_line", "pattern": "\d{4}\-(0?[1-9]|1[012])\-(0?[1-9]|[12][0-9]|3[01])", "name": "new_log_start_with_date"}}'
deploy:
replicas: 1
placement:
constraints: [node.role == manager]
command: >
-c logging_collector=on
-c log_directory=/logs/beesquad/
-c log_filename='%Y-%m-%d-ws.db.log'
-c log_statement=all
-c log_line_prefix='%m [%p] %d %a %u %h %c '
-c log_file_mode=0664
networks:
- datadog
- default
thank you
Hi @mathroc ,
Integration configuration via docker labels has been ported and tested on Agent6 and should work without any change in your templates. This is strange. Could you make sure you are running 6.0.0-rc.2, and send a flare to our support team, referencing this github issue?
As for logs, AD is not yet supported for logs collections. Pinging @NBParis.
Hello,
So indeed as @xvello label annotation is not available yet for logs. For now you would need to use yaml files in a mounted directory as explained here: https://app.datadoghq.com/logs/onboarding/container
You would then be able to filter by label or to not filter at all and collect the logs from all your containers.
I'll make sure to keep you updated regarding any update on annotations support for logs.
ah yes, I was on the 6.0.0-rc.1and it’s working again with 6.0.0-rc.2 !
I’ll rename this issue to mention only the logs
Hi @mathroc, you should be able to use docker labels to start collecting logs from your containers, there is few limitations for now though, for more context see https://github.com/DataDog/datadog-agent/issues/1736.