Skip to content

pg_metricus

Sends custom metrics from PL/pgSQL code to socket-based aggregators such as Brubeck or Graphite.

pg_metricus_c · Sends custom metrics from PL/pgSQL code to socket-based aggregators such as Brubeck or Graphite.

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
100438pg_metricuspg_metricus_c1.0STATMITC

Usage

Sources:

pg_metricus sends application-formatted metrics from SQL or PL/pgSQL to an IPv4 UDP endpoint such as Brubeck or Graphite. It provides transport only: the caller must construct the exact line protocol expected by the receiver.

Core Workflow

Configure the destination address and port, reload PostgreSQL configuration, and install the extension in a chosen schema.

pg_metricus.host = '10.9.5.164'
pg_metricus.port = 8124
CREATE SCHEMA metricus;
CREATE EXTENSION pg_metricus SCHEMA metricus;

SELECT metricus.send_metric(
  format(E'%s.%s:%s|%s\n', 'db.sql', 'latency', 12, 'ms')
);

The endpoint settings can be changed with a configuration reload; the extension does not require preloading.

SQL Object and Delivery Semantics

  • send_metric(text) RETURNS void sends the supplied bytes as one UDP datagram.

Version 1.0 accepts only a numeric IPv4 address because its C implementation uses inet_pton with AF_INET. UDP provides no acknowledgement or retry, and the function does not make delivery transactional: a datagram already sent remains sent even if the surrounding database transaction later aborts. Avoid placing secrets in metric text, and treat successful return as a local send attempt rather than confirmation that the collector stored the metric.

Table reader