Skip to content

Instantly share code, notes, and snippets.

@ckelner
Last active January 3, 2018 04:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ckelner/a0c978f20b42facec6946e5c97f8dccc to your computer and use it in GitHub Desktop.
Save ckelner/a0c978f20b42facec6946e5c97f8dccc to your computer and use it in GitHub Desktop.
Testing reporting mysql metrics from a remote host from two different hosts running the datadog agent (3 hosts total, one MySQL, two dd-agents)

Datadog: 1 MySQL reported by 2 hosts

  • Run MySQL via Docker:
    docker run -p 3306:3306 --name kelnerhax-mysql -e MYSQL_ROOT_PASSWORD=<password> -d mysql:latest
    
  • docker inspect <container-name> to get the container ip from `NetworkSettings.IPAddress"
  • docker exec -it <container-name> /bin/bash to get on the docker container
  • Follow https://docs.datadoghq.com/integrations/mysql/#prepare-mysql
    • mysql -u root --password=<password>
    • CREATE USER 'datadog'@'%' IDENTIFIED BY '<dd-mysql-password>';
    • GRANT REPLICATION CLIENT ON *.* TO 'datadog'@'%' WITH MAX_USER_CONNECTIONS 5;
    • GRANT PROCESS ON *.* TO 'datadog'@'%';
    • exit
  • Use https://github.com/ckelner/datadog-mysql-vagrant to spin up to vagrants and configure the mysql check
    • Use the special virtualbox IP 10.0.2.2 to connect to the mysql instance via the host on port 3306
    • Spin up a second vagrant the same way using ./second_vagrant/Vagrantfile in the repo

This will result in hosts reporting the same metric (duplicate) as seen here:

two-hosts-one-db

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment