Skip to content

Monitor database with Percona Monitoring and Management (PMM)

In this section you will learn how to monitor Percona Server for MongoDB with Percona Monitoring and Management (PMM) .

Note

Only PMM 2.x versions are supported by the Operator.

PMM is a client/server application. It includes the PMM Server and the number of PMM Clients running on each node with the database you wish to monitor.

A PMM Client collects needed metrics and sends gathered data to the PMM Server. As a user, you connect to the PMM Server to see database metrics on a number of dashboards .

PMM Server and PMM Client are installed separately.

Install PMM Server

You must have PMM server up and running. You can run PMM Server as a Docker image, a virtual appliance, or on an AWS instance. Please refer to the official PMM documentation for the installation instructions.

Install PMM Client

To install PMM Client as a side-car container in your Kubernetes-based environment, do the following:

  1. Authorize PMM Client within PMM Server.

    1. Generate the PMM Server API Key . Specify the Admin role when getting the API Key.

    Warning: The API key is not rotated automatically.

    1. Edit the deploy/secrets.yaml secrets file and specify the PMM API key for the PMM_SERVER_API_KEY option.
    2. Apply the configuration for the changes to take effect.

      $ kubectl apply -f deploy/secrets.yaml -n <namespace>
      
    1. Edit the deploy/secrets.yaml secrets file and specify the following:

    2. The user name of your PMM Server (admin by default) in the PMM_SERVER_USER key

    3. The password you set for the PMM Server during its installation in the PMM_SERVER_PASSWORD key.

    4. Apply the configuration for the changes to take effect.

      $ kubectl apply -f deploy/secrets.yaml -n <namespace>
      
  2. Update the pmm section in the deploy/cr.yaml file:

    • Set pmm.enabled=true.
    • Specify your PMM Server hostname / an IP address for the pmm.serverHost option. The PMM Server IP address should be resolvable and reachable from within your cluster.

      pmm:
        enabled: true
        image: percona/pmm-client:{{pmm2recommended}}
        serverHost: monitoring-service
    
    3. Apply the changes:

    $ kubectl apply -f deploy/cr.yaml -n <namespace>
    
  3. Check that corresponding Pods are not in a cycle of stopping and restarting. This cycle occurs if there are errors on the previous steps:

    $ kubectl get pods -n <namespace>
    $ kubectl logs <cluster-name>-rs0-0 -c pmm-client -n <namespace>
    

Check the metrics

Let’s see how the collected data is visualized in PMM.

  1. Log in to PMM server.
  2. Click MongoDB from the left-hand navigation menu. You land on the Instances Overview page.
  3. Select your cluster from the Clusters drop-down menu and the desired time range on the top of the page. You should see the metrics.
  4. Click MongoDBOther dashboards to see the list of available dashboards that allow you to drill down to the metrics you are interested in.

Enable profiling

Starting from the Operator version 1.12.0, MongoDB operation profiling is disabled by default. To analyze query execution on the PMM Query Analytics dashboard, you should enable profiling explicitly. You can pass options to MongoDB in several ways.

For example, update the configuration subsection of the deploy/cr.yaml:

spec:
  ...
  replsets:
    - name: rs0
      size: 3
      configuration: |
        operationProfiling:
          slowOpThresholdMs: 200
          mode: slowOp
          rateLimit: 100

Optionally, you can specify additional parameters for the pmm-admin add mongodb command in the pmm.mongodParams and pmm.mongosParams keys for mongod and mongos Pods respectively.

Info: Please take into account that the Operator automatically manages common MongoDB Service Monitoring parameters , such as username, password, service-name, host, etc. Assigning values to these parameters is not recommended and can negatively affect the functionality of the PMM setup carried out by the Operator.

When done, apply the edited deploy/cr.yaml file:

$ kubectl apply -f deploy/cr.yaml

Update the secrets file

The deploy/secrets.yaml file contains all values for each key/value pair in a convenient plain text format. But the resulting Secrets Objects contains passwords stored as base64-encoded strings. If you want to update the password field, you need to encode the new password into the base64 format and pass it to the Secrets Object.

To encode a password or any other parameter, run the following command:

$ echo -n "password" | base64 --wrap=0
$ echo -n "password" | base64

For example, to set the new PMM API key in the my-cluster-name-secrets object, do the following:

$ kubectl patch secret/my-cluster-name-secrets -p '{"data":{"PMM_SERVER_API_KEY": '$(echo -n new_key | base64 --wrap=0)'}}'
$ kubectl patch secret/my-cluster-name-secrets -p '{"data":{"PMM_SERVER_API_KEY": '$(echo -n new_key | base64)'}}'

Get expert help

If you need assistance, visit the community forum for comprehensive and free database knowledge, or contact our Percona Database Experts for professional support and services. Join K8S Squad to benefit from early access to features and “ask me anything” sessions with the Experts.


Last update: 2024-11-15