# Set up Percona Monitoring and Management

> Set up the monitoring of your database infrastructure

To use Percona Monitoring and Management (PMM) to monitor your database infrastructure, complete the procedure in this section to integrate Percona Server for MongoDB (PSMDB) with PMM.

## Prerequisites

Before you deploy PMM, ensure that this setup is complete:

* When deploying Self-Hosted Deployment, you have enabled PMM, that is, you have set the `enable_percona_monitoring` setting to **true** in the [Terraform variables file](./deployment.md#3.1-set-the-terraform-variables).
* The resources `ClusterRole` and `ClusterRoleBinding` exist in the Kubernetes cluster.

## 1. Expose the PMM web interface

To expose the PMM web interface, complete these steps:

1. Create an Ingress resource for the PMM web interface in your Kubernetes cluster.

2. Add a DNS record that points to the PMM service in your DNS provider, for example, **Route 53**.

3. Ensure that the PMM service is accessible through the configured domain name.

## 2. Access the PMM web interface

To access the PMM web interface, complete these steps:

1. Go to the PMM web interface using your configured domain name.

2. Sign in with the `admin` username. To retrieve the password, run this command:

   ```sh
   kubectl get secret pmm-admin-password -o jsonpath="{.data.GF_SECURITY_ADMIN_PASSWORD}" | base64 --decode
   ```

## 3. Create a token to integrate PSMDB with PMM

To integrate PSMDB with PMM, create a token in PMM:

1. In the PMM web interface, go to **Administration** > **Service Accounts**.

2. Select **Add Service Account**.

3. Enter a descriptive name for the service account, choose **Admin** role and then select **Create**.

4. Select **Add service account Token**.

5. Copy the generated API key, and then save it to a secure location.

6. Update the Terraform variable `psmdb_pmm_server_token` with the API key in your configuration file.

   The entry must have this format:

   ```hcl
   psmdb_pmm_server_token = "<YOUR_PMM_TOKEN>"
   ```

7. To apply the changes, run this command:

   ```sh
   cd aws/terraform
   make apply-us-east-1
   ```

## 4. Validate the metrics collection

To validate that the metrics collection is working correctly, complete these verification steps:

1. Ensure that there are no access errors. To check the PSMDB pod logs, run this command:

   ```sh
   kubectl logs psmdb-db-rs0-0 -c pmm-client
   ```

2. To verify that the metrics are being collected in the PMM web interface, consult the MongoDB metrics in the **MongoDB** section.
