Skip to content
This repository has been archived by the owner on Dec 17, 2023. It is now read-only.

Collecting metrics from exact services

Alexey Lesovsky edited this page May 5, 2021 · 1 revision

Collecting metrics from exact services.

TLDR: disable auto-discovery, specify connection settings of specific service.

pgSCV uses auto-discovery for searching local services. For all services found, pgSCV starts collecting metrics. Sometimes you only need collecting metrics from specific service, not the all. In this case, specify needed services manually - auto-discovery will be disabled and pgSCV will collect metrics only from specified services.

  1. Add the services section into pgscv.yaml and describe the services - specify its type and connection string. Take a look on conninfo string - this is standard libpq keyword/value formatted string.
services:
  "postgres:5432"
    service_type: "postgres"
    conninfo: "host=127.0.0.1 port=5432 dbname=postgres user=postgres"

Tag postgres:5432 is considered as unique ID and will be attached as the service_id label to each metric. Hence it is possible to collect metrics from hosts where pgSCV cannot be installed, e.g. Windows hosts or Amazon RDS and so on.

  1. Restart pgSCV.
systemctl restart pgscv
  1. Check journalctl logs.
journalctl -fu pgscv 
{"level":"info","service":"pgscv","time":"2021-05-05T07:55:08Z","message":"read configuration from pgscv.yaml"}
{"level":"info","service":"pgscv","time":"2021-05-05T07:55:08Z","message":"*** IMPORTANT ***: pgSCV by default collects information about user queries. Tracking queries can be disabled with 'no_track_mode: true' in config file."}
{"level":"info","service":"pgscv","time":"2021-05-05T07:55:08Z","message":"no-track mode disabled"}
{"level":"info","service":"pgscv","time":"2021-05-05T07:55:08Z","message":"registered new service [system:0]"}
{"level":"info","service":"pgscv","time":"2021-05-05T07:55:08Z","message":"registered new service [postgres:5432]"}
{"level":"info","service":"pgscv","time":"2021-05-05T07:55:08Z","message":"accepting requests on http://127.0.0.1:9890/metrics"}

Check out message about registered service [postgres:5432].