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.
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
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 ...
DD_API_KEY instead of API_KEY The status command did not exist when using the old dd-agent etc.
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