How to monitor nginx with docker-compose with datadog

Monitor nginx with Datadog

How to monitor nginx with paid monitoring tool datadog. However, when setting up the datadog agent with docker-compose ...

Official documentation (almost useless) https://docs.datadoghq.com/ja/integrations/nginx/?tab=host

First, look at this and insert the nginx status_module. (Up to this point, docker is not relevant)

In short, it's OK if you can see the status on localhost: 81.

Official documentation

There is a sample setting to monitor nginx using docker-compose! !! !!

For container environments, refer to the AutoDiscovery Integration Templates Guide and apply the following parameters:

So, even if I go to the guided page, there is no sample of docker-compose ... https://docs.datadoghq.com/ja/agent/kubernetes/integrations/?tab=kubernetes

The point is, should I make a config file .yaml, copy it, and mount it? Sample file? what is that?

conf.d/<INTEGRATION_NAME>.d/conf.yaml

So, the settings for nginx are like these

<Integration name>	nginx
<Initial configuration>Blank or{}
<Instance configuration>	{"nginx_status_url": "http://%%host%%:81/nginx_status/"}

I don't even know! !! !! !! What should I put in ? where? What file name is it? The official documentation is too unfriendly! !! !! !!

Since datadog is a paid tool, there are few articles that I have tried ...

So, the following is the correct docker-compose.yml file.

docker-compose.yml

version: "3.8"
services:
  web:
    build:
      context: ./docker/nginx
    ports:
      - 80:80
    #Delete irrelevant settings
    #The settings so far have nothing to do with datadog. There is no need to open port 81.
    #From here is the setting of the core part that logs with datadog
    links:
      - dd-agent:dd-agent
    depends_on:
      - dd-agent
    labels:
      com.datadoghq.ad.check_names: '["nginx"]'
      com.datadoghq.ad.init_configs: '[{}]'
      com.datadoghq.ad.instances: '[{"nginx_status_url": "http://%%host%%:81/nginx_status"}]'
      com.datadoghq.ad.logs: '[{"source": "nginx", "service": "web"}]'


#datadog container settings
  dd-agent:
    container_name: dd-agent
    image: datadog/agent:7
    environment:
      - DD_API_KEY=Write your API key here
      - DD_APM_ENABLED=true
      - DD_LOGS_ENABLED=true
      - DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL=true
      - DD_AC_EXCLUDE="name:dd-agent"
    volumes:
     - /var/run/docker.sock:/var/run/docker.sock
     - /proc/:/host/proc/:ro
     - /sys/fs/cgroup:/host/sys/fs/cgroup:ro
    ports:
      - "8126:8126/tcp"

Now launch the container and check the existence with docker ps. OK if it is healty.

$ docker ps
CONTAINER ID        IMAGE                COMMAND                  CREATED             STATUS                    PORTS                                      NAMES
577f6b34b971        datadog/agent:7      "/init"                  39 seconds ago      Up 37 seconds (healthy)   8125/udp, 0.0.0.0:8126->8126/tcp           dd-agent

If alive, check the status of datadog.

$ docker exec -it dd-agent agent status

With this command, if there is a character string nginx in check and something seems to be done, it is OK. (Omitted because it is long)


    nginx (3.9.0)
    -------------
      Instance ID: nginx:[OK]
      Configuration Source: docker:docker://
      Total Runs: 4
      Metric Samples: Last Run: 7, Total: 28
      Events: Last Run: 0, Total: 0
      Service Checks: Last Run: 1, Total: 4
      Average Execution Time : 5ms
      Last Execution Date : 2020-10-27 10:20:20.000000 UTC
      Last Successful Execution Date : 2020-10-27 10:20:20.000000 UTC
      metadata:
        version.major: 1
        version.minor: 18
        version.patch: 0
        version.raw: 1.18.0
        version.scheme: semver

There are no samples or articles of such basic application combinations, and there is no datadog ... it's tough ...

Hamari point

DD_API_KEY instead of API_KEY The status command did not exist when using the old dd-agent etc.

Articles that were a little helpful

https://y-ohgi.com/2019-aws-handson/datadog/docker-compose/ https://tech.griphone.co.jp/2018/12/02/advent-calendar-20181202/ https://qiita.com/comefigo/items/4d867a39ad2fd5b9bbd2 https://qiita.com/spesnova/items/b1f2cc4e33ddf7cea285

Recommended Posts

How to monitor nginx with docker-compose with datadog
How to write docker-compose
How to create docker-compose
How to monitor SPA site transitions with WKWebView
How to send custom metrics and events to datadog with laravel in docker-compose environment
How to number (number) with html.erb
How to update with activerecord-import
How to scroll horizontally with ScrollView
How to get started with slim
How to use mssql-tools with alpine
How to start Camunda with Docker
[Note] How to restart the Windows container set up with docker-compose
How to use MinIO with the same function as S3 Use docker-compose
How to crop an image with libGDX
How to adjustTextPosition with iOS Keyboard Extension
How to share files with Docker Toolbox
How to compile Java with VsCode & Ant
[Java] How to compare with equals method
[Android] How to deal with dark themes
[Rails] How to use rails console with docker
How to switch thumbnail images with JavaScript
[Note] How to get started with Rspec
How to do API-based control with cancancan
Launch Nginx + Spring Boot application with docker-compose
How to update related models with accepts_nested_attributes_for
How to set JAVA_HOME with Maven appassembler-maven-plugin
How to implement TextInputLayout with validation function
How to handle sign-in errors with devise
How to delete data with foreign key
How to test private scope with JUnit
How to deal with Precompiling assets failed.
How to achieve file upload with Feign
How to write and explain Dockerfile, docker-compose
How to run Blazor (C #) with Docker
How to build Rails 6 environment with Docker
Think about how to follow container operation best practices with Nginx containers
How to deploy to AWS using NUXTJS official S3 and CloudFront? With docker-compose
How to use args :, environment :, env_file: and .env files with docker-compose command
How to limit IP address only to a specific directory with laravel + nginx
How to download Oracle JDK 8 rpm with curl
[Java] How to test for null with JUnit
How to mock each case with Mockito 1x
How to mock each case with PowerMock + Mockito1x
How to use MyBatis2 (iBatis) with Spring Boot 1.4 (Spring 4)
How to save to multiple tables with one input
How to test interrupts during Thread.sleep with JUnit
How to search multiple columns with gem ransack
How to use Java framework with AWS Lambda! ??
[Swift] How to link the app with Firebase
How to create multiple pull-down menus with ActiveHash
How to use Java API with lambda expression
How to get started with Eclipse Micro Profile
How to insert all at once with MyBatis
How to write test code with Basic authentication
How to build API with GraphQL and Rails
How to use nfs protocol version 2 with ubuntu 18.04
How to use docker compose with NVIDIA Jetson
Error deploying rails5 + Mysql to heroku with Docker-compose
How to create member variables with JPA Model
How to verify variable items with WireMock's RequestBodyMatching
How to use nginx-ingress-controller with Docker for Mac