Setup Beautiful Datadog Logs On Your Docker Containers

Reading Time: < 1
Datadog is a monitoring service for cloud-scale applications, providing monitoring of servers, databases, tools, and services, through a SaaS-based data analytics platform.
docker logging with datadog

Table of Contents

Introduction

Datadog is a monitoring service for cloudscale applications. It provides monitoring of servers, databases, tools, and services through a SaaSbased data analytics platform. 

Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and ship it all out as one package. By doing this, the application will always run the same, regardless of the environment it is running in. Therefore, the container concept is an interesting solution to deploy applications.

How to setup datadog for docker ?

To setup datadog for docker, you need to first install the datadog agent on your host machine. You can find instructions on how to do this in the datadog documentation. 

Once the agent is installed, you need to create a dockercompose.yml file in the root of your project. This file will tell docker how to build and run your containers. 

In the dockercompose.yml file, you will need to add the following:

				
					version: "3.2"

services:
  datadog-agent:
    image: gcr.io/datadoghq/agent:7
    container_name: datadog-agent
    environment:
      - DD_API_KEY=yourKey
      - DD_SITE=datadoghq.eu
      - DD_APM_ENABLED=false
      - DD_APM_NON_LOCAL_TRAFFIC=false
      - DD_LOGS_ENABLED=true
      - DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL=true
      - DD_LOGS_CONFIG_DOCKER_CONTAINER_USE_FILE=true
      - DD_CONTAINER_EXCLUDE=name:datadog-agent
      - DD_PROCESS_AGENT_ENABLED=false
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /var/lib/docker/containers:/var/lib/docker/containers:ro
      - /proc/:/host/proc/:ro
      - /opt/datadog-agent/run:/opt/datadog-agent/run:rw
      - /sys/fs/cgroup/:/host/sys/fs/cgroup:ro

  www-garygitton-fr:
    container_name: www-garygitton-fr
    image: wordpress:5.6
    restart: always
    labels:
      - "com.datadoghq.tags.service=www-garygitton-fr"
      - "com.datadoghq.tags.env=production"
      - "com.datadoghq.tags.version=5.6"
    environment:
      DD_SERVICE: www-garygitton-fr
      DD_ENV: production
      DD_VERSION: 5.6
      DD_AGENT_HOST: datadog-agent
      DD_TRACE_AGENT_PORT: 8126

				
			

Share it on:

Twitter
LinkedIn
Facebook
WhatsApp

About the Author

Gary Gitton
Hello, I'm Gary Gitton - an accomplished Software Engineer, Tech Lead, specializing in PHP, API Engineering, DevOps, and Cloud Management. Throughout my career, I've had the privilege to enhance multiple software solutions with my expertise in multiple languages and platforms. I bring my unique blend of technical and business acumen to every project, ensuring efficient, scalable, and innovative outcomes. I'm also passionate about fostering a culture of continuous learning, mentoring developers, and leading projects with agile methodologies. Whether concocting a bespoke API or orchestrating cloud environments, I'm committed to delivering quality and excellence. Let's connect and transform your vision into a digital reality.

You might also like