Extend Metrics for Percona Monitoring and Management Without Modifying Code

Extend Metrics for Percona Monitoring and Management Without Modifying Code

PREVIOUS POST
NEXT POST

Percona Monitoring and Management (PMM) provides an excellent solution for system monitoring. Sometimes, though, you’ll have the need for a metric that’s not present in the list of node_exporter metrics out of the box. In this post, we introduce a simple method and show how to extend the list of available metrics without modifying the node_exporter code. It’s based on the textfile collector.

Enable the textfile collector in pmm-client

This collector is not enabled by default in the latest version of pmm-client. So, first let’s enable the textfile collector.

Notice that the whole list of default collectors has to be re-enabled. Also, don’t forget to specify the directory for reading files with the metrics (–collector.textfile.directory=”/tmp”). The exporter reads files with the extension .prom

Add a crontab task

The second step is to add a crontab task to collect metrics and place them into a file.

Here are the cron commands for collecting the number of running and stopping docker containers.

The result of the commands is placed into the files  /tmp/docker_running.prom and /tmp/docker_running.prom and read by exporter.

Look - we got a new metric!

Adding the crontab tasks by using a script

Also, we have a few bash scripts that make it much easier to add crontab tasks.

The first one allows you to collect the logged-in users and the size of Innodb data files.

Modifying the cron job - a script

You may use the suggested names of files and metrics or set new ones.

The second script is more universal. It allows us to get the size of any directories or files. This script can be placed directly into a crontab task. You should just specify the list of monitored instances (e.g. /var/log /var/cache/apt /var/lib/mysql/ibdata1)

So, I hope this has provided useful insight into how to set up the collection of new PMM metrics without the need to write code. Please feel free to use the scripts or configure commands similar to the ones provided above.

More resources you might enjoy

If you are new to PMM, there is a great demo site of the latest version, showing you those out of the box metrics. Or how about our free webinar on monitoring Amazon RDS with PMM?

PREVIOUS POST
NEXT POST

Share this post

Comments (2)

  • Vishal Saxena Reply

    pmm-admin add linux:metrics — –collectors.enabled=diskstats,filefd,filesystem,loadavg,meminfo,netdev,netstat,stat,time,uname,vmstat,textfile –collector.textfile.directory=”/tmp”

    does not work…i tried with only giving “–collectors.enabled=textfile” and –collector.textfile.directory=”/tmp” but in all cases the log shows that its enabling default set of collectors which does not include textfile collector

    October 19, 2018 at 10:56 am
    • Vadim Yalovets Reply

      The collector is enabled by default in the pmm-admin release 1.16.0. It’s configured to check *.prom text files from the folder /usr/local/percona/pmm-client/textfile-collector.

      This release is scheduled on the next week.

      October 22, 2018 at 5:57 am

Leave a Reply