Exporter2Perfdata - Connecting Postgres Monitoring Tools

Yogesh Sharma

3 min read

pgMonitor is a popular open source monitoring tool based on Prometheus, Exporters, and Grafana. We have many customers leveraging pgMonitor when using the Crunchy Postgres for Kubernetes and Crunchy Postgres. pgMonitor ships out-of-the-box with its own configurations for easy setup of exporters and has a special set of SQL queries for Postgres monitoring using the postgres_exporter.

We often hear questions from customers like "Can I use Prometheus Exporters with Icinga2 or Nagios?". We are excited to offer exporter2perfdata as an open source project from Crunchy Data. Exporter2Perfdata will read metrics from any Prometheus Exporters so that they can be consumed by Icinga2 / Nagios. This opens up a lot of possibilities to use Prometheus Exporter with the Crunchy sponsored tool, pgMonitor.

Cloning and Compiling

Exporter2Perfdata is written in go (golang), you will clone the git repo on a system that can compile go programs.

git clone https://github.com/CrunchyData/exporter2perfdata.git
cd exporter2perfdata
make

Usage

$ ./exporter2perfdata -h

exporter2perfdata: 2.0

Usage of exporter2perfdata:
  -action string
        exporter Metric name [REQUIRED]
  -compare-type int
        Compare Type 0=None,1=GT,2=LT,3=NEQ
  -critical string
        Critical threshold
  -exclude string
        <domain><value> to include
  -expression string
        expression for calculated values
  -force-ok
        Force UNKNOWN to return OK status
  -include string
        <domain><value> to include
  -text-values int
        Treat values as TEXT
  -url string
        exporter url http(s)://<ip | domain><:port> [REQUIRED]
  -version
        Print version
  -warning string
        Warning threshold

Configuration

Copy the generated binary exporter2perfdata to the target system (ex: Icinga2 server or Icinga2 satellite server)

sudo mkdir -p /usr/lib64/nagios/plugins/
sudo cp exporter2perfdata /usr/lib64/nagios/plugins/exporter2perfdata
sudo chmod 755 /usr/lib64/nagios/plugins/exporter2perfdata

Usually the target folder is created when the plugins package for Icinga2 or Nagios is installed.

Copy provided exporter2perfdata.conf to the target system (ex: Icinga2 server or Icinga2 satellite server)

sudo mkdir -p /share/icinga2/include/plugins-contrib.d/
sudo cp exporter2perfdata.conf /share/icinga2/include/plugins-contrib.d/exporter2perfdata.conf
sudo chmod 644 /share/icinga2/include/plugins-contrib.d/exporter2perfdata.conf

Usually the target folder is created when the plugins package for Icinga2 or Nagios is installed.

At this point you can being using the exporter2perfdata to set up the Icinga2 or Nagios configuration.

How do I use it?

Here is an Icinga2 metric example based on exporter2perfdata:

apply Service "ccp_pg_ready" {
  import "generic-service"

  check_command    = "exporter2perfdata"
  vars.pg_url      = host.vars.pg_url_node

  vars.pg_action   = "ccp_pg_ready"
  /* Checks to see if the given system is NOT (compare = 3) a primary (return value 2) by default.
   * Set on a per-host basis to be able to check whether a system is no longer a replica (return value 1)
   */
  vars.pg_compare  = "3"
  vars.pg_critical  = host.vars.ccp_pg_ready_critical
  if (host.vars.ccp_pg_ready_critical == "") {
          vars.pg_critical = "2"
  }

  assign where host.vars.node_common == "true"
}

Our Commitment to Production Ready Postgres

Crunchy Data is proud to bring additional open source monitoring tools to the Postgres community and our customers. Crunchy Postgres provides an integrated high availability solution for enterprises with "always on" data requirements. This solution provides performance requirements, high availability, load balancing, and scalability. Give our exporter2perfata a try by visiting exporter2perfdata on github or to read more about it.

Avatar for Yogesh Sharma

Written by

Yogesh Sharma

May 26, 2022 More by this author