Max connections


Job details

Name: Max connections
Platform: Postgres
Category: Capacity
Description: Checks the size of the log file.
Long description:
Version: 1.1
Default schedule: 15m
Requires engine install: No
Compatibility tag: .[type=‘instance’]/instance[databasetype=‘postgres’]

Parameters

Name Default value Description
warning_threshold 30 Number of sessions left until max_connections parameter is reached in order to generate warning
alarm_threshold 10 Number of sessions left until max_connections parameter is reached in order to generate alarm

Job Summary

SELECT COUNT(*) FROM pg_stat_activity;

Details of the Monitoring Job

The monitoring job specifically checks if the number of sessions connected to a PostgreSQL instance is nearing its max_connections parameter value. It classifies the status into two main thresholds:

Logic Implementation

Using JavaScript, this job calculates the number of active sessions and triggers alerts based on the thresholds:

Reporting Template

The report provides a structured output:

Output Table

The output from this monitoring job is presented in a table format which includes:

Details
Connected sessions vs. Max sessions

This table combines both the maximum number of sessions and the number of connected sessions, providing a clear view of the database’s capacity usage.

In summary, this job is vital for preventing database overloads and ensuring smooth operations by constantly monitoring and alerting on session usage relative to capacity.