Skip to content
Documentation
Updated 7 minutes to read
Markdown

Unlock the full potential of your PostgreSQL environments with the Nodinite Database Monitoring Agent. This page shows you how to leverage custom PSQL scripts for proactive monitoring, instant alerts, and self-service management—empowering both integration experts and business users.

  • ✅ Monitor PostgreSQL health and business data using your own PSQL logic
  • ✅ Instantly receive alerts and automate remediation with Remote Actions
  • ✅ Empower self-service for business users to execute pre-defined scripts
  • ✅ Centralize monitoring and management for all your PostgreSQL resources

Bring your own PSQL logic and Nodinite will monitor and alert you whenever there is a problem detected!

To use this feature, provide AdHoc PSQL statements with your business logic as described in the examples on this page. As for SQL Server, a PostgreSQL SQL Statement holds one connection and a list of monitoring statements on its Monitoring Statements (n) tab. The Database Monitoring Agent creates one Resource for each enabled monitoring statement. Each monitoring statement returns its evaluated state, which you can monitor in Monitor Views and push external alerts using any of the Alarm Plugins.

PostgreSQL PSQL Statements are grouped by the Category PostgreSQL - SQL Statements.

'PostgreSQL - SQL Statements' Category
Example: Monitor View displaying PostgreSQL SQL Statement resources grouped by category.

  • Your custom-built PostgreSQL - SQL Statements are listed in Nodinite as Resources, where the Display Name of the monitoring statement becomes the Resource name. It must be unique within the configuration, also across its SQL Statements.
graph LR subgraph "Configuration" c["fal:fa-code 1 SQL Statement"] --> m["fal:fa-traffic-light n monitoring statements"] m --> r[fal:fa-lightbulb n Resources] end

Each enabled monitoring statement is manifested as a Resource. The tabs and validation work as described on SQL Statements, with the differences under Monitoring Statements tab.

What are the key features for Monitoring SQL Statements?

Section titled “ What are the key features for Monitoring SQL Statements?”
  • State Evaluation – Monitor and evaluate the state based on your own PSQL logic. See PSQL/Stored procedure code examples further down in this guide.
  • Actions – Support for the execution of Remote Actions

The different possible evaluated states for your custom coded SQL Statements are provided in the table below:

Icon State Status Description Actions
Unavailable Resource not available Evaluation of the 'SQL Statement' is not possible either due to network or security-related problems Review prerequisites
Error Error state raised SQL Statement reports that one or more major problems/errors were detected by raising an exception Edit
Warning Warning state raised SQL Statement reports that one or more minor problems were detected by raising an exception with state warning Edit
OK Online SQL Statement is valid, executes and reports that no problems were detected Edit

The Database Monitoring Agent automatically monitors each configured SQL Statement. You can add new and modify existing SQL Statements using the Remote Configuration dialogue for the Database Monitoring Agent.

From the PostgreSQL databases tab, configure global settings. Then click on the Size check tab.

A Nodinite Administrator can add new SQL Statements from the Remote Configuration dialogue, as detailed in Add or manage a Monitoring Agent.

From the PostgreSQL statements tab for the PostgreSQL Database Connection configuration, click the Add button.

Any number of SQL Statements can be provided, but make sure that each one is fast to execute or you may end up hogging the agent and probably resulting in various timeouts.

Add button
Example: Add button location for creating new PostgreSQL SQL Statement configurations.

Expand the accordion to edit available properties.

SQL Statements configuration
Example: PostgreSQL SQL Statement configuration properties panel.

New 7.13
A SQL Statement of a PostgreSQL Database configuration has the tabs General, Monitoring Statements (n), User Action Scripts (n), and Authentication. The Monitoring Statements tab lists one accordion per monitoring statement; click Add for another one.
PostgreSQL Database configuration Contoso PostgreSQL with a SQL Statement on its Monitoring Statements (2) tab, the monitoring statements Contoso Open Orders and Contoso Failed Orders, and the Add button (7.13)
The Monitoring Statements tab of a PostgreSQL SQL Statement: the same list as for SQL Server.

The fields and the save rules are the ones of SQL Server, with two differences:

  • The Authentication tab has only the Connection String; there is no impersonation.
  • Every monitoring statement needs an Execute Command, also a disabled one. On SQL Server, only the enabled monitoring statements of an enabled SQL Statement need one.

A Display Name used twice in one configuration, also across its SQL Statements, stops the save (PSQL-DUPLICATE-003).

The properties below describe one monitoring statement.

You can manage the following properties:

  • Enabled
  • ApplicationId
  • Display Name
  • Command Type
  • Command Text
  • Description

Flag to set if monitoring for this configuration is enabled or not.

Select the Id of which Application to associate this Resource (SQL Statement configuration) with.

You can manage the user-friendly Name. This setting must be unique for each SQL Statement configuration.

The Type of 'SQL Command', select one of the following:

  • Text – For AdHoc PSQL Statements

Enter your Command text, see examples further down in this guide.

  • Execute Command – the SQL command(s) to execute

An AdHoc PSQL query with your own custom logic.

Description – user-friendly description for SQL Statement resource

The following Actions are currently implemented:

Modify SQL Statement configuration directly from the Resource using Remote Actions.

You must click 'Save' or 'Save and close' for changes to persist. The new settings/thresholds are evaluated on the next synchronization.
Save and Close buttons
Example: Save and Save and close button options.

Save and close saves and closes the dialogue.
Cancel closes the dialogue without saving any changes.


The outcome (State) from the logic in your PostgreSQL - SQL Statements is based on whether you raise an exception or not.

Internally, the Database Monitoring Agent executes the Execute Scalar method. This will pick up data from the first column at the first row, and set this as Log Text unless you raised an exception.

The LogText presented for the PostgreSQL Statement configuration (The Resource) comes from your last SELECT statement (1st row, 1st column) or from the Exception. If you do not select anything the Log Text simply becomes empty.

Return Code Evaluated State LogText
No exception raised OK From SELECT operation (1st column)
Throw exception Error From HINT text
Throw exception with SQLSTATE '01000' Warning From HINT text

Example of using the SQL Statement with Command Type set to Text. This example counts the rows in the actual table. Depending on your logic, different states can be returned.

DO $$ BEGIN
DECLARE counter integer;
BEGIN
counter:= 0;
SELECT count(*) into counter FROM public."LogEvents" WHERE "ValidationFailed"=true;
IF (counter=0) THEN -- OK
--return query SELECT 'OK';
ELSEIF (counter<10) THEN -- WARNING
RAISE EXCEPTION SQLSTATE '01000'
USING HINT = 'Make sure to clean these up manually after inspection of the content within the ValidationFailedText column';
ELSE -- EXCEPTION
RAISE EXCEPTION
USING HINT = 'Make sure to clean these up manually after inspection of the content within the ValidationFailedText column';
END IF;
END;
END $$;

Add or manage Monitor View

Secure Custom Database Scripts and Actions
Azure SQL Statements
SQL Statements
Database Monitoring Agent
SQL Categories
Resources
Monitoring Agents
Monitor Views

...

Version:
Release date: N/A
Loading...

Explore Nodinite for 30 days – completely free

  • Find out why this is the leading O&M software
  • Prove your business case
  • Test the self-service for the business side

Loading...

See how Nodinite resolves your technical issues, in a LIVE Demo!

Once you submit this request:

  • We will give you a short call to understand the issues you want to tackle.
  • Understand solutions you have tried and why were you not happy with them.
  • Book a convenient slot for a LIVE demo!

Loading...