Forbid idle connections in postgres exporter and limit amount of parallel connections

Description

We have to limit amount of connections utilized by postgresql_exporter. For that we need to roll-over databases with configured limit of parallel connections and fetch required metrics one-by-one db. Also we need to close connections as soon as they not needed anymore (forbid hanging/idle conns).

How to test

  1. Create Posgres instance with >100 databases

  2. Setup PMM and add this PG to it, with auto-discovery feature enabled

  3. Check amount of opened connections in PG: SELECT COUNT(*) FROM pg_stat_activity WHERE state IN ('idle', 'active'); , it should be ~5-6 (not tens)

If problematic in QA lets plan another v2 patch release (v3 merging withdrawal)

How to document

New parameter `--max-exporter-connections=10` was added to `pmm-admin` command, which controls how many connection postgres exporter can open.

Smart Checklist

hide

Activity

Show:
Done

Details

Assignee

Reporter

Priority

Components

Labels

Needs QA

Yes

Needs Doc

No

Planned Version/s

Fix versions

Story Points

Smart Checklist Progress

Smart Checklist

Created February 5, 2024 at 4:17 PM
Updated November 13, 2024 at 9:48 AM
Resolved March 22, 2024 at 11:28 AM