I tried to enable logs collecting with datadog ansible role,
but I can’t figure out why the logs are not sent to the Datadog ui
I found an example of a playbook in the role GitHub repo,
JavaScript
x
- hosts: servers
roles:
- { role: datadog.datadog, become: yes }
vars:
datadog_api_key: "<YOUR_DD_API_KEY>"
datadog_agent_version: "7.16.0"
datadog_config:
tags:
- "<KEY>:<VALUE>"
- "<KEY>:<VALUE>"
log_level: INFO
apm_config:
enabled: true
logs_enabled: true # available with Agent v6 and v7
datadog_checks:
process:
init_config:
instances:
- name: ssh
search_string: ['ssh', 'sshd' ]
- name: syslog
search_string: ['rsyslog' ]
cpu_check_interval: 0.2
exact_match: true
ignore_denied_access: true
ssh_check:
init_config:
instances:
- host: localhost
port: 22
username: root
password: <YOUR_PASSWORD>
sftp_check: True
private_key_file:
add_missing_keys: True
nginx:
init_config:
instances:
- nginx_status_url: http://example.com/nginx_status/
tags:
- "source:nginx"
- "instance:foo"
- nginx_status_url: http://example2.com:1234/nginx_status/
tags:
- "source:nginx"
- "<KEY>:<VALUE>"
#Log collection is available on Agent 6 and 7
logs:
- type: file
path: /var/log/access.log
service: myapp
source: nginx
sourcecategory: http_web_access
- type: file
path: /var/log/error.log
service: nginx
source: nginx
sourcecategory: http_web_access
# datadog_integration is available on Agent 6.8+
datadog_integration:
datadog-elastic:
action: install
version: 1.11.0
datadog-postgres:
action: remove
network_config:
enabled: true
i have just a tomcat server logging to a file and I want datadog to take those logs file and send them to my datadog account!
thanks in advance
JavaScript
# my code
- name: install the agent on targets
include_role:
name: datadog.datadog
vars:
datadog_api_key: "myApiKey"
datadog_site: "datadoghq.com"
datadog_config:
log_level: INFO
apm_config:
enabled: true
logs_enabled: true
logs:
- type: file
path: /home/ubuntu/web-app/tomcatlogs/logs/*.log
service: myapp
source: tomcat
Advertisement
Answer
I figured out how to do it,
at the bottom line is just about specifying a service (tomcat, nginx, java …) and the Ansible role will create the files needed to complete your configuration,
hope this can help someone
JavaScript
- name: install the agent on targets
include_role:
name: datadog.datadog
vars:
datadog_api_key: "YOUR_API"
datadog_site: "datadoghq.com"
datadog_config:
log_level: INFO
apm_config:
enabled: true
logs_enabled: true
datadog_checks:
tomcat:
logs:
- type: file
path: /home/ubuntu/web-app/tomcatlogs/logs/*.log
service: myapp
source: tomcat