Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,27 @@ Before you start, ensure you have:
- [PMM Server installed](../../install-pmm-server/index.md) and running with a known IP address or hostname accessible from the Client node.
- [PMM Client installed](../../install-pmm-client/index.md) and the nodes are registered with PMM Server.
- admin privileges to install and configure PMM Client on the host.
- preconfigured MongoDB user with appropriate monitoring privileges, or sufficient privileges to create the required roles and users.
- MongoDB server version 6.0 or higher. PMM may work with MongoDB versions as old as 4.4, but we recommend using MongoDB 6.0+ for complete feature support.

## Step 1: Set up MongoDB monitoring permissions
| Query source | Database QAN permissions | Host file access |
| :--- | :--- | :--- |
| **Profiler** (default) | `find` on `system.profile` in `pmmMonitor` role | Not required |
| **Mongolog** | Not required | Read access to the MongoDB log file for `pmm-agent` — [Step 1](#step-1-configure-query-analytics) |

Set up MongoDB with a dedicated user for PMM and the required permissions. First, create custom roles with the necessary privileges, then assign them to a PMM-specific user.
### Create MongoDB monitoring user

PMM needs a dedicated MongoDB user for **dashboard metrics** (`mongodb_exporter`), regardless of the Query Analytics query source.

Create custom roles with the necessary privileges, then assign them to a PMM-specific user.

Role privileges depend on:

- MongoDB version: 8.0+ requires the additional `directShardOperations` role for shard metrics
- Required features: basic monitoring only, or monitoring plus backup management.
- Query collection method: profiler or diagnostic log.
- Required features: basic monitoring only, or monitoring plus backup management

### Create monitoring role
#### Create pmmMonitor role

After connecting to your MongoDB instance, create a custom role with the privileges required for metric collection, working with Query Analytics (QAN) and optionally creating/restoring backups:

#### Minimum privileges

This role grants the essential minimum privileges needed for monitoring and QAN:
Include all three privilege blocks below for **Profiler** (default). If you use **mongolog**, omit the `system.profile` block.

```javascript
db.getSiblingDB("admin").createRole({
Expand All @@ -44,13 +45,13 @@ db.getSiblingDB("admin").createRole({
},
{
"resource": { "db": "", "collection": "system.profile" },
"actions": [ "dbStats", "collStats", "indexStats" ]
}
"actions": [ "find", "dbStats", "collStats", "indexStats" ]
}
],
"roles": [ ]
})
```

#### Full backup management privileges

If you plan to use PMM's backup features, also create a role with full backup management privileges:
Expand All @@ -68,7 +69,7 @@ db.getSiblingDB("admin").createRole({
});
```

### Create user and assign created role
#### Create user and assign roles

After creating the custom roles, create the PMM user and assign the roles based on your MongoDB version and requirements:

Expand Down Expand Up @@ -140,9 +141,9 @@ After creating the custom roles, create the PMM user and assign the roles based
})
```

## Step 2: Configure query source for MongoDB query analytics
## Step 1: Configure Query Analytics

PMM offers two methods for collecting MongoDB queries. Choose based on your environment's requirements and constraints.
Complete the section for your query source before [adding the service](#step-2-add-mongodb-service-to-pmm).

### Compare query source methods

Expand All @@ -159,6 +160,9 @@ PMM offers two methods for collecting MongoDB queries. Choose based on your envi
| Scales with DB count | Linear degradation| Constant |

=== "MongoDB Profiler (Default)"
!!! note "Using mongolog?"
Skip this section and use [Diagnostic Log](#diagnostic-log-recommended-for-scale) instead.

Choose this standard method for simple setups with fewer than 100 databases, remote MongoDB instances, or when you need real-time query collection.

The MongoDB Profiler stores query performance data in `system.profile` collections for each database. PMM continuously reads from these collections to provide query analytics.
Expand All @@ -168,7 +172,7 @@ PMM offers two methods for collecting MongoDB queries. Choose based on your envi
- Real-time query collection and analysis
- No additional file system access required
- Works with managed MongoDB services
- Immediate data availability after profiling is enabled
- Immediate data availability after profiling is enabled

To enable the MongoDB Profiler, choose one of the following methods:

Expand Down Expand Up @@ -222,27 +226,30 @@ PMM offers two methods for collecting MongoDB queries. Choose based on your envi
db.setProfilingLevel(2, {slowms: 0})
```

If you have already [added a service](#step-3-add-mongodb-service-to-pmm), you should remove it and re-add it after changing the profiling level.
If you have already [added a service](#step-2-add-mongodb-service-to-pmm), you should remove it and re-add it after changing the profiling level.

=== "Diagnostic Log (Recommended for scale)"
Choose this method for production environments with 100+ databases, when experiencing connection pool issues, or when monitoring mongos routers.
!!! note "Using Profiler?"
Skip this section and use [MongoDB Profiler](#mongodb-profiler-default) instead.

Choose this method for production environments with 100+ databases, connection pool issues, or `mongos` routers.

Available from PMM 3.3.0+, this method reads query data directly from MongoDB's log files instead of querying the database. This eliminates connection pool usage and reduces performance impact.
Available from PMM 3.3.0+, this method reads query data from MongoDB log files instead of `system.profile`.

Key advantages:

- Zero database connections required for metrics collection
- Eliminates connection pool errors completely
- Scales linearly regardless of database count
- Identical query analytics data as traditional profiler
- Zero database connections for query collection
- Scales regardless of database count
- Supports `mongos` routers

Prerequisites for Diagnostic Log:
#### Requirements

- MongoDB 5.0+ (tested with 5.0.20-17)
- Write access to the configured log directory for MongoDB process
- Read access to log file for PMM Agent user
- MongoDB process has write access to the log directory
- `pmm-agent` user has read access to the log file
- Monitoring user has `getCmdLineOpts` (included in `clusterMonitor` from Prerequisites)

To configure mongolog for MongoDB:
To configure mongolog for MongoDB:
{.power-number}

1. Choose one of the following methods to configure MongoDB to log slow operations to the diagnostic log file:
Expand Down Expand Up @@ -321,9 +328,9 @@ PMM offers two methods for collecting MongoDB queries. Choose based on your envi
- Avoid moving/renaming log files as this breaks mongolog's file tail
- Do not delete active log files during rotation

## Step 3: Add MongoDB service to PMM
## Step 2: Add MongoDB service to PMM

After configuring your database server, add a MongoDB service using either the user interface or the command line.
After completing [Prerequisites](#prerequisites) and [Step 1](#step-1-configure-query-analytics) for your chosen query source, add a MongoDB service using either the user interface or the command line. Select the query source that matches your Step 1 configuration (`profiler` or `mongolog`).

!!! caution alert alert-warning "Important"
To monitor MongoDB sharded clusters, PMM requires access to all cluster components. Make sure to add all config servers, all shards, and at least one or two mongos routers. Otherwise, PMM will not be able to correctly collect metrics and populate dashboards.
Expand Down Expand Up @@ -409,7 +416,7 @@ After configuring your database server, add a MongoDB service using either the u

1. Select **Inventory > Add service > MongoDB**.

2. Fill in the required fields.
2. Fill in the required fields, including **Query Source** (`Profiler` or `Diagnostic log (mongolog)`) to match your [Step 1](#step-1-configure-query-analytics) configuration.

3. Click **Add service**.

Expand All @@ -430,7 +437,7 @@ After configuring your database server, add a MongoDB service using either the u

Only variables already set in the `pmm-agent` environment will be passed to the exporter.

## Step 4: Verify MongoDB service configuration
## Step 3: Verify MongoDB service configuration

After adding MongoDB service to PMM, verify that it's properly configured and collecting data. This ensures your monitoring setup is working correctly.
{.power-number}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ Easily connect your MySQL databases—whether self-hosted or running on AWS EC2
Get your MySQL instance connected to PMM in just a few steps:
{.power-number}

1. Create a dedicated MySQL user with the required permissions. If you are using an [Administrative Connection](https://dev.mysql.com/doc/refman/8.4/en/administrative-connection-interface.html), you will also need to grant the `SERVICE_CONNECTION_ADMIN` privilege to the `pmm` user:
1. Create a dedicated MySQL user with the permissions required for **metrics collection**. If you are using an [Administrative Connection](https://dev.mysql.com/doc/refman/8.4/en/administrative-connection-interface.html), you will also need to grant the `SERVICE_CONNECTION_ADMIN` privilege to the `pmm` user:

```sql
-- Create PMM user with required permissions
-- Create PMM user with permissions for metrics collection
CREATE USER 'pmm'@'localhost' IDENTIFIED BY 'StrongPassword123!' WITH MAX_USER_CONNECTIONS 10;
GRANT SELECT, PROCESS, REPLICATION CLIENT, RELOAD ON *.* TO 'pmm'@'localhost';
```

Query Analytics setup depends on the query source. See [Configure data source](#configure-data-source).

2. Register your MySQL instance with PMM:

```sh
Expand Down Expand Up @@ -54,15 +56,20 @@ For monitoring Amazon RDS MySQL instances, see [Connect Amazon RDS instance](../

1. **[Prerequisites](#prerequisites)**: Ensure PMM Server is running and PMM Client is installed
2. **[Create PMM user](#create-a-database-account-for-pmm)**: `CREATE USER 'pmm'@'localhost' IDENTIFIED BY '<StrongPassword>'`
3. **[Grant permissions](#create-a-database-account-for-pmm)**: `GRANT SELECT, PROCESS, REPLICATION CLIENT, RELOAD ON *.* TO 'pmm'@'localhost'`
4. **[Configure data source](#configuring-data-sources)**: Enable Slow Query Log or Performance Schema
5. **[Add service](#adding-mysql-services-to-pmm)**: Use PMM UI or command line to add the MySQL instance
3. **[Grant permissions](#create-a-database-account-for-pmm)**: `GRANT SELECT, PROCESS, REPLICATION CLIENT, RELOAD ON *.* TO 'pmm'@'localhost'` (metrics collection only)
4. **[Configure data source](#configuring-data-sources)**: Enable Slow Query Log or Performance Schema, and complete the query-source-specific permissions
5. **[Add service](#adding-mysql-services-to-pmm)**: Use PMM UI or command line to add the MySQL instance, selecting the matching query source
6. **[Verify connection](#verifying-the-setup)**: Check PMM Inventory and dashboards for data

### Prerequisites

Before connecting MySQL to PMM, review the prerequisites for your monitoring setup:

| Query source | Database QAN permissions | Host file access |
| :--- | :--- | :--- |
| **Performance Schema** (`perfschema`) | `SELECT` on Performance Schema (included in metrics grants) | Not required |
| **Slow query log** (`slowlog`) | Not required beyond metrics grants | Read access to the slow query log file for `pmm-agent` |

=== "Local MySQL monitoring"
- [PMM Server is installed](../../../install-pmm-server/index.md) and running.
- [PMM Client is installed](../../../install-pmm-client/index.md) and the nodes are registered with PMM Server.
Expand Down Expand Up @@ -95,7 +102,7 @@ For security best practices, connect PMM Client to your database using a dedicat
- Avoid common words or patterns
- Never use default, test, or example passwords in production

This example creates a pmm user account that has just enough access to collect monitoring data without full administrative privileges:
This example creates a pmm user for **dashboard metrics**. For Query Analytics, see [Configure data source](#configure-data-source).

=== "On MySQL 5.7/MariaDB 10.x"

Expand Down Expand Up @@ -141,11 +148,15 @@ Here are the benefits and drawbacks of Slow query log and Performance Schema met
### Configure data source

=== "Slow query log"

The *slow query log* records the details of queries that take more than a certain amount of time to complete.

With the database server configured to write this information to a file rather than a table, PMM Client parses the file and sends aggregated data to PMM Server via the Query Analytics part of `pmm-agent`.


!!! note "Using Performance Schema?"
Skip this section and use [Performance Schema](#performance-schema) instead.

PMM reads the slow query log file via `pmm-agent`. Ensure:

- `pmm-agent` has read access to the slow query log file (root/sudo may be required with RPM/DEB packages)
- The monitoring user has `SELECT` to read `@@slow_query_log_file`; `RELOAD` only if using automatic log rotation (`--size-slow-logs`)

#### Settings

| Variable | Value | Description |
Expand Down Expand Up @@ -241,9 +252,12 @@ Here are the benefits and drawbacks of Slow query log and Performance Schema met
If you prefer to handle log rotation manually, such as with [logrotate][LOGROTATE], you can disable PMM Client's automatic log rotation. To do this, set a negative value for the `--size-slow-logs` option when adding a service with the `pmm-admin add` command.

=== "Performance Schema"

To configure a MySQL-based database server to use Performance Schema as a source of metrics:


!!! note "Using slowlog?"
Skip this section and use [Slow query log](#slow-query-log) instead.

The `SELECT` grant from [Create a database account for PMM](#create-a-database-account-for-pmm) is sufficient. Enable and configure Performance Schema as described below.

#### Applicable versions

- **Percona Server for MySQL**: 5.6, 5.7, 8.0, 8.4
Expand Down Expand Up @@ -523,7 +537,7 @@ The **command line** (`pmm-admin`) deploys an exporter directly on the database
- **Port**: MySQL port (default: 3306)
- **Username**: The PMM user created earlier
- **Password**: Your PMM user password
- **Query Source**: Choose between **Slow Log** or **Performance Schema**
- **Query Source**: Choose **Slow Log** or **Performance Schema** to match your [Configure data source](#configure-data-source) setup
- **PMM Agent**: Select which PMM agent should monitor this instance
- **Disable query examples**: Check this option to prevent collection of actual query values in QAN. When enabled, PMM will continue to collect query metrics and statistics but will not store the actual query examples with real data values.
- **Connection timeout**: How long PMM should wait when connecting to this service. Increase this for remote or high-latency databases. If the connection times out, PMM retries the next time it collects metrics. Leave empty to use the default of 2s.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,13 @@ For a complete list of ports and detailed network configuration options, see [Ne

To ensure successful database monitoring with PMM, confirm the following:

- **Monitoring users**: Create database accounts with the required permissions
- **Log access**: Enable file system access to database logs (where applicable)
- **Performance Schema**: Recommended for enhanced MySQL monitoring
- **Monitoring users**: Permissions for dashboard metrics — see database-specific setup guides
- **Query Analytics**: Depends on query source (Profiler/mongolog, slowlog/perfschema) — see the same guides

=== ":material-database: Core databases"

- [MySQL monitoring requirements](../install-pmm-client/connect-database/mysql/mysql.md#create-a-database-account-for-pmm)
- [MongoDB monitoring requirements](../install-pmm-client/connect-database/mongodb.md#create-a-database-account-and-set-permissions)
- [MongoDB monitoring requirements](../install-pmm-client/connect-database/mongodb.md#prerequisites)
- [PostgreSQL monitoring requirements](../install-pmm-client/connect-database/postgresql.md#create-a-database-account-for-pmm)

=== ":material-cloud: Cloud services"
Expand Down
6 changes: 3 additions & 3 deletions documentation/docs/quickstart/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ Once PMM is set up, choose the database or the application that you want it to m
To connect a MongoDB database:
{ .power-number}

1. Run the following command in `mongo` shell to create a role with the monitoring permissions:
1. Run the following command in `mongo` shell to create the `pmmMonitor` role. Include the `system.profile` block for Profiler QAN (default); omit it for mongolog.

```
db.createRole({
Expand All @@ -255,8 +255,8 @@ Once PMM is set up, choose the database or the application that you want it to m
},
{
"resource": { "db": "", "collection": "system.profile" },
"actions": [ "dbStats", "collStats", "indexStats" ]
}
"actions": [ "find", "dbStats", "collStats", "indexStats" ]
}
],
"roles": []
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Use the filters at the top to narrow down to specific environments, clusters, or
![MongoDB Backup Details dashboard](../../images/BackupDetails_Dashboard.png)

!!! note
This dashboard requires MongoDB services to be added with the `--cluster` parameter. If panels show no data, see [Add MongoDB service to PMM](../../install-pmm/install-pmm-client/connect-database/mongodb.md#step-3-add-mongodb-service-to-pmm).
This dashboard requires MongoDB services to be added with the `--cluster` parameter. If panels show no data, see [Add MongoDB service to PMM](../../install-pmm/install-pmm-client/connect-database/mongodb.md#step-2-add-mongodb-service-to-pmm).

## Overview

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Use these grids to confirm all cluster components are healthy before investigati
- use the same `--cluster` name for all components of your sharded cluster.
- add config servers, shard nodes, and mongos routers as separate services.

For details, see [Add MongoDB services via CLI](../../install-pmm/install-pmm-client/connect-database/mongodb.md#step-3-add-mongodb-service-to-pmm).
For details, see [Add MongoDB services via CLI](../../install-pmm/install-pmm-client/connect-database/mongodb.md#step-2-add-mongodb-service-to-pmm).

Example:

Expand Down
Loading