Hi, I want to share a docker-compose configuration to run Percona Server for MongoDB in combination with PMM monitoring and QAN query analytics.
This is very handy in developing locally on a laptop. You can connect the application to the database and immediately see the results in PMM.
The docker-compose configuration will launch with a single command:
- Percona Server for MongoDB with profiling enabled.
- PMM Server to open PMM in a browser via localhost
- PMM Client to send metrics from MongoDB to PMM.
It may need to be adjusted for your OS. I will be glad to receive suggestions and feedback.
- Create a mongod.conf file to enable profiling.
mongod.conf
operationProfiling:
mode: all
slowOpThresholdMs: 200
rateLimit: 100
- Create docker-compose.yaml . Replace the image for your OS, I use macOS c ARM. Specify the path to mongod.conf
version: '3.7'
services:
mongodb:
image: "percona/percona-server-mongodb:7.0-arm64" // Replace the image to match your OS.
volumes:
- mongodata:/data/db
- ./mongod.conf:/etc/mongod.conf:ro
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: password
MONGO_INITDB_DATABASE: database
ports:
- "27017:27017"
command: ["mongod", "--config", "/etc/mongod.conf"]
pmm-server:
image: percona/pmm-server:2
platform: "linux/amd64"
container_name: pmm-server
restart: always
ports:
- 8081:80
- 443:443
volumes:
- pmm-data:/srv
environment:
- DISABLE_TELEMETRY=0
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost"]
interval: 30s
timeout: 10s
retries: 5
pmm-client-mongodb:
image: percona/pmm-client:2
platform: "linux/amd64"
container_name: pmm-client-mongodb
depends_on:
pmm-server:
condition: service_healthy
environment:
PMM_AGENT_SERVER_ADDRESS: pmm-server
PMM_AGENT_SERVER_USERNAME: admin
PMM_AGENT_SERVER_PASSWORD: admin
PMM_AGENT_SERVER_INSECURE_TLS: 1
PMM_AGENT_CONFIG_FILE: config/pmm-agent.yaml
PMM_AGENT_SETUP: 1
PMM_AGENT_SETUP_FORCE: 1
PMM_AGENT_PRERUN_SCRIPT: "pmm-admin status --wait=10s; pmm-admin add mongodb --username=root --password=password --host=mongodb --port=27017 --query-source=profiler"
volumes:
mongodata:
pmm-data:
- Run the command
docker-compose up -d
. - Connect your application to the database via
localhost
. Open PMM in a browser vialocalhost
.
Dashboard example