Using PMM With External Monitoring Services
Let's see how you can use Percona Monitoring and Management's new support for external monitoring services to give you more versatility in your tool selection.
Join the DZone community and get the full member experience.
Join For FreePercona Monitoring and Management (PMM) is a free and open-source platform for managing and monitoring MySQL and MongoDB performance. You can run PMM in your own environment for maximum security and reliability. It provides thorough time-based analysis for MySQL and MongoDB servers to ensure that your data works as efficiently as possible.
Starting with version 1.4.0 and improved in 1.7.0, PMM supports external monitoring services. This means you can plug in Prometheus exporters for technologies not directly provided by Percona. For example, you can start monitoring the metrics of your PostgreSQL database host, Memcached or Redis.
Exporters Overview
Applications store their metrics in arbitrary formats, and Prometheus exporters collect them and produce (or export to) a consistent format of key-value pairs. The keys refer to metric types and values are numbers in the float 64 format. Due to the diversity of formats that applications may use, you should program a specific exporter for each format. However, if you decide to make the metrics of your application available via PMM you may consider using one of existing Prometheus exporters.
Currently, PMM offers exporters for MySQL (mysqld_exporter) and MongoDB (mongodb_exporter) database management systems. Built-in exporters also exist for Percona XtraDBCluster, MariaDB, RDS, and Aurora via mysqld_exporter and for ProxySQL (via proxysql_exporter). These exporters are made available as monitoring services that you can add or remove as necessary. In addition, PMM includes the node_exporter to capture the host level Linux metrics such as CPU, Load, and disk resources.
Using Exporters
On the computer where the PMM client is installed and connected to a PMM server, make use of the pmm-admin utility to add any built-in monitoring service directly. There is no extra effort in this case: the added monitoring service will run its exporter and all required configuration updates are made automatically to make the metrics available in the web interface for further analysis in Query analytics and Metrics monitor.
In case of external monitoring services, you need to locate, download, set up and run the specific Prometheus exporter to collect metrics. When it is ready, you can add it as a monitoring service:
pmm-admin add external:service job_name [instance] --service-port=PORT_NUMBER
This command adds an external monitoring service bound to the Prometheus job that you specify as the job_nameparameter. You should also provide the port associated with this Prometheus job as the value of the service-port parameter. The instance parameter is optional. By default, it is assigned the name of the host where you run pmm-admin.
Example 1: Adding a PostgreSQL Monitoring Service
In order to add an external monitoring service for a PostgreSQL database server, make sure to install and configure your PostgreSQL server. Then, select a PostgreSQL Prometheus exporter from the list available from the Prometheus site, such as PostgreSQL metric exporter for Prometheus. Refer to the documentation for this exporter for details about how to install and set it up.
As soon as your Prometheus exporter can collect metrics from your PostgreSQL database server, you are ready to add this exporter as a monitoring service. Make sure that you have access to a configured PMM server and your PMM client has been set up to use it. Use the pmm-admin utility, which is part of PMM client, to add the PostgreSQL monitoring service. Assuming postgresql is the name of this monitoring service, your command should look like this:
pmm-admin add external:service --service-port=PORT_NUMBER postgresql
It is time now to display the metrics on the PMM Server. Open Metrics Monitor and check the Advanced Data Explorationdashboard. This can dashboard visualize a lot of metrics including those exposed by external monitoring services. In the Host field, select your host. Use the Metric field to select a metric.
Setting up an external monitoring service requires extra work compared to adding built-in monitoring services. However, by using external monitoring services you can considerably extend the capabilities of your PMM installation.
Note that running the pmm-admin list command lists the added external monitoring services. They also appear in the JSONoutput, too. To remove an external service use the remove (or its short form rm) command:
pmm-admin rm external:service --service-port=PORT_NUMBER NAME_OF_EXTERNAL_MONITORING_SERVICE
$ sudo pmm-admin list
pmm-admin 1.7.0
PMM Server | 192.0.2.2 (password-protected)
Client Name | postgres01
Client Address | 192.0.2.3
Service Manager | unix-systemv
Job name Scrape interval Scrape timeout Metrics path Scheme Target Labels Health
postgresql 1s 1s /metrics http 192.0.2.3:9187 instance="postgres01" UP
Example 2: Adding a Redis Monitoring Service
To start with, you must install a Prometheus exporter for Redis (this exporter is listed on the Prometheus Exporters and Integrations page) on the machine where your PMM client runs. The following command adds this exporter as an external monitoring service (run it as a superuser or use sudo). This time the command has an extra parameter:
$ sudo pmm-admin add external:service redis --service-port 9121 redis01
External service added.
Notice that we use Redis Server as the last parameter passed to pmm-admin add external:service command. The last positional parameter is a label that you assign to this particular instance.
pmm-admin add external:service --service-port=PORT_NUMBER NAME_OF_EXTERNAL_MONITORING_SERVICE [INSTANCE_LABEL]
You may choose any name for this purpose. Make sure to use quotes if you decide to use a label made of two or more words.
$ sudo pmm-admin list
pmm-admin 1.7.0
PMM Server | 127.0.0.1
Client Name | percona
Client Address | 172.17.0.1
Service Manager | linux-systemd
No services under monitoring.
Job name Scrape interval Scrape timeout Metrics path Scheme Target Labels Health
redis 1m0s 10s /metrics http 172.17.0.1:9121 instance="redis01" UP
To view Redis related metrics you need to open the Advanced Data Exploration dashboard on your PMM Server. The redis01label automatically appears in the Host field in the Advanced Data Exploration dashboard. In the Host field, select the redis01 option and choose a metric to view from the Metric field, such as redis_exporter_scrapes_total.
Other Ways to Add External Services
The pmm-admin add external:service command is the recommended way to add an external monitoring service. There exist other, more specific, methods. The pmm-admin add external:metrics adds external Prometheus exporters job to metrics monitoring.
Published at DZone with permission of Borys Belinksy, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments