# Running Percona Server for MongoDB with PMM monitoring and QAN query analytics in Docker Compose

**URL:** <https://forums.percona.com/t/running-percona-server-for-mongodb-with-pmm-monitoring-and-qan-query-analytics-in-docker-compose/33236>\
**Category:** Percona Server for MongoDB\
**Created:** [September 19, 2024, 9:29am UTC](https://forums.percona.com/t/running-percona-server-for-mongodb-with-pmm-monitoring-and-qan-query-analytics-in-docker-compose/33236 "2024-09-19T09:29:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![daniil.bazhenov](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/daniil.bazhenov/32/62_2.png) [@daniil.bazhenov](https://forums.percona.com/u/daniil.bazhenov)\
**Post date:** [September 19, 2024, 9:29am UTC](https://forums.percona.com/t/running-percona-server-for-mongodb-with-pmm-monitoring-and-qan-query-analytics-in-docker-compose/33236/1 "2024-09-19T09:29:27Z")

</div>

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:

1. Percona Server for MongoDB with profiling enabled.
2. PMM Server to open PMM in a browser via localhost
3. 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.

1. Create a mongod.conf file to enable profiling.  
mongod.conf

```auto
operationProfiling:
  mode: all
  slowOpThresholdMs: 200
  rateLimit: 100

```

1. Create docker-compose.yaml . Replace the image for your OS, I use macOS c ARM. Specify the path to mongod.conf

```auto
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:

```

1. Run the command `docker-compose up -d`.
2. Connect your application to the database via `localhost`. Open PMM in a browser via `localhost`.

Dashboard example

 ![PMM-MongoDB-Docker](https://us1.discourse-cdn.com/flex019/uploads/percona1/original/3X/4/f/4fa85f00fe7b612e63c243c2f3f5db11bc6c183f.jpeg)

---

<div class="post-metadata">

**Author:** ![ernestojpg](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/ernestojpg/32/19042_2.png) [@ernestojpg](https://forums.percona.com/u/ernestojpg)\
**Post date:** [September 23, 2024, 6:59pm UTC](https://forums.percona.com/t/running-percona-server-for-mongodb-with-pmm-monitoring-and-qan-query-analytics-in-docker-compose/33236/2 "2024-09-23T18:59:04Z")

</div>

Hell @daniil.bazhenov !

Thanks for sharing. Just a quick note. To make it more compatible, I don’t think you have to indicate the specific platform that you want to use, in your docker-compose file.

Your Docker client will automatically use/choose the corresponding image given your architecture, if it is available, or it will emulate your platform if there is no image available for your Platform.

Best regards.  
Ernesto.

---

<div class="post-metadata">

**Author:** ![daniil.bazhenov](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/daniil.bazhenov/32/62_2.png) [@daniil.bazhenov](https://forums.percona.com/u/daniil.bazhenov)\
**Post date:** [September 24, 2024, 5:45am UTC](https://forums.percona.com/t/running-percona-server-for-mongodb-with-pmm-monitoring-and-qan-query-analytics-in-docker-compose/33236/3 "2024-09-24T05:45:24Z")

</div>

Thanks for your comment, maybe the problem is with my Docker Desktop, but when I don’t specify a platform, the launch fails ending in an error.

I’ll try to test again and will improve this.

I use this thing every day as I develop my self-study project.

> **[GitHub - dbazhenov/github-stat: Golang application for testing MySQL, Postgres,...](https://github.com/dbazhenov/github-stat)**
>
> Golang application for testing MySQL, Postgres, MongoDB databases. Gets data in JSON format from GitHub API and saves it to a database.
