boltZharp Docs
databaseMonitors

Private Databases

Monitor PostgreSQL, MySQL, Redis and MongoDB — by connecting to them directly, or through the Zharp agent when they aren't reachable from the internet.

All four engines sit behind one entry in the type picker, Database monitor. Its first field, Connection, decides how the database is checked:

ConnectionHow it worksUse it when
PublicZharp's checkers connect to the database on every check and run a query.The database accepts connections from the internet.
PrivateThe Zharp agent, on a server next to the database, reports on it. Zharp never connects to the database.The database is behind a firewall or on a private network.

Public: Zharp connects directly

  1. 1
    Pick the type

    On the Monitors page click New, choose Database monitor under Monitor type, and leave Connection on Public.

  2. 2
    Paste a connection string

    Connection string takes the full URI, credentials included. Its scheme decides the engine: postgres:// or postgresql://, mysql:// or mariadb://, mongodb:// or mongodb+srv://, redis:// or rediss://.

    postgresql://monitor:secret@db.example.com:5432/production

    Prefer separate fields? Click Enter details instead and fill in Database type, Host, Database name, Username and Password. Database name is required for PostgreSQL and MySQL; Redis takes a password only. MongoDB also has Auth database, the database the user is defined in — admin when left empty, which is where Atlas and most installations keep their users.

  3. 3
    Adjust the connection settings (optional)

    Under Advanced settings → Connection settings:

    SettingDefaultWhat it does
    PortThe engine's default5432, 3306, 27017 or 6379 when left empty.
    Health check querySELECT 1 (PostgreSQL, MySQL), PING (Redis)Run on every check. A query that errors marks the monitor down.
    Connection timeout10 seconds5, 10, 20, 30 or 60 seconds.
    Query timeout30 seconds10, 30, 60 or 120 seconds.
    Use SSL/TLSRequired (Preferred for Redis)See the table below.
    Expected row countAt least 1Any, At least 1, Exactly 1 or None (empty result). PostgreSQL and MySQL only.
  4. 4
    Create it

    Click Create monitor. The first check is due straight away.

SSL/TLS options

The setting means the same for all four engines:

OptionWhat the check does
RequiredEncrypted; the certificate is not verified. A server that doesn't speak TLS fails the check.
PreferredTries an encrypted connection first. If the server doesn't support TLS, it connects again without it and the check carries on. A wrong password or a refused connection is not retried.
Verify certificateEncrypted, and the certificate must chain to a trusted authority and match the host name. Otherwise the check fails.
DisabledNo TLS — except PostgreSQL and MySQL hosts on rds.amazonaws.com or containing .db., which still connect encrypted without verification.
  • Redis: a rediss:// connection string always connects over TLS, whatever the dropdown says. With redis:// or Enter details instead, the dropdown decides. A Redis server without TLS needs Preferred or Disabled; with Required the check fails and its message says so. New Redis monitors start on Preferred, and Redis monitors saved earlier with the old Required default were moved to Preferred when Redis began honouring this setting. A user name in the connection string (redis://monitor:secret@host) logs in as that ACL user.
  • MongoDB: with Disabled, the connection string decides — mongodb+srv:// URIs connect over TLS, as MongoDB always does for them. When Preferred falls back, half the connection timeout is spent on the encrypted attempt.

Queries for Redis and MongoDB

  • Redis: a command as you'd type it in redis-cli, for example INFO replication. Without one, the check is a PING.
  • MongoDB: a command document, written as JSON or as db.runCommand({ ... }) / db.adminCommand({ ... }), for example db.adminCommand({ "ping": 1 }).

A public MongoDB check connects with the connection string as you entered it. With Enter details instead, it builds one from the fields: Username and Password are sent and checked against Auth database, and Database name is the database the check reads.

warning
Public means public

A public database monitor must point at an address on the internet. Zharp refuses loopback (localhost, 127.x.x.x, ::1), link-local (169.254.x.x, fe80::) and private ranges (10.x, 172.16–31.x, 192.168.x, 100.64–127.x, fc00::/7) — when you save, and again on every check, after resolving the host name. Use a private monitor for a database on a private network. See Private Networks.

Private: through the Zharp agent

A private monitor reads what the Zharp agent reports. The agent connects to the database locally and sends its numbers to Zharp over HTTPS, so the database never has to accept a connection from outside, and its password never leaves the server.

  1. 1
    Install the agent on a server that can reach the database

    Usually the database's own server. At install the agent looks for PostgreSQL, MySQL, Redis and MongoDB. Redis without a password is collected straight away; the others are listed on the host under Integrations → Zharp Agent as Needs setup.

  2. 2
    Give the agent a monitoring user

    Open the host and click Set up next to the database. It shows the commands below with a password already filled in — see the monitoring user each engine needs. The database moves to Collecting within a minute.

  3. 3
    Create the monitor

    Click New, choose Database monitor, set Connection to Private, and pick the database in Agent connection. Each one is listed by engine and server — for example PostgreSQL on db-01 — with its address added when that isn't localhost. The engine comes from the database you pick.

    A database only appears here once the agent has reported on it. If the list says No connections available, finish the setup on the server first.

  • A private monitor has no Connection settings section (port, query, timeouts, SSL, row count): the agent decides how it connects, so the form hides them.
  • The agent can watch a database on another machine it can reach: --host and --port for PostgreSQL and MySQL, --endpoint host:port for Redis and MongoDB.
On the agent's server
# a database on another machine the agent can reach
sudo zharp-collector add postgres --host 10.0.0.12 --port 5432 --password 'choose-a-password' --db app
sudo zharp-collector add mongo --endpoint 10.0.0.20:27017 --password 'choose-a-password'

Several databases of one engine

One agent can report on any number of PostgreSQL, MySQL, Redis or MongoDB servers. The first of an engine is added as above. Each further one needs --name, made of letters, digits, - or _:

On the agent's server
# the first PostgreSQL on this agent needs no name; every further one gets its own
sudo zharp-collector add postgres --name orders --host 10.0.0.12 --password 'choose-a-password' --db orders
sudo zharp-collector add postgres --name billing --host 10.0.0.13 --password 'another-password' --db billing
  • Each named database is listed separately — on the host as PostgreSQL (orders), and in Agent connection as PostgreSQL "orders" on db-01 — and gets monitors of its own.
  • Running add again without --name keeps the first database's settings and only updates its password; the command reminds you to use --name for another database. Running it again with a name that exists does the same for that database.
  • Agents set up before names existed keep reporting their one database per engine, unchanged.

The monitoring user each engine needs

These are the commands the dashboard gives you under Set up. The dashboard fills in a random password made in your browser; Zharp doesn't store it. On Windows, run the zharp-collector line in an elevated PowerShell without sudo.

PostgreSQL

-- as a superuser in psql
CREATE USER zharp_monitor WITH PASSWORD 'choose-a-password';
GRANT pg_monitor TO zharp_monitor;
On the server
sudo zharp-collector add postgres --password 'choose-a-password'

MySQL

-- as root in mysql
CREATE USER 'zharp_monitor'@'localhost' IDENTIFIED BY 'choose-a-password';
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'zharp_monitor'@'localhost';
FLUSH PRIVILEGES;
On the server
sudo zharp-collector add mysql --password 'choose-a-password'

MongoDB

// as an admin in mongosh
use admin
db.createUser({ user: "zharp_monitor", pwd: "choose-a-password", roles: [{ role: "clusterMonitor", db: "admin" }] })
On the server
sudo zharp-collector add mongo --password 'choose-a-password'

Redis

# only when Redis has a password (requirepass); without one the agent collects it by itself
sudo zharp-collector add redis --password '<redis password>'

What a private monitor checks

The agent reports every 30 seconds. On each check, the monitor reads the latest report and compares it with fixed limits — they can't be changed from the dashboard today.

EngineGoes down whenMessage
PostgreSQLConnections in use pass 90% of max_connectionsHigh connection usage: 93.5%
MySQLConnected threads pass 90% of max_connectionsHigh connection usage: 91.2%
MySQLMySQL refused a connection because max_connections was reached, within the last check frequency plus 30 secondsMySQL refused 3 connections: max_connections (151) reached
RedisMemory used passes 90% of maxmemory (only when maxmemory is set)High memory usage: 92.4%
RedisMore than 1,000 connected clientsHigh connection count: 1042
MongoDBMore than 1,000 current connectionsHigh connection count: 1200
MongoDBMore than 5,000 operations per secondHigh operations/sec: 6150.4

When a private monitor goes down

Before any limit is compared, the monitor checks that the report is there and recent:

SituationStatus and message
Just created, no report yetPending — Waiting for the agent's first report on PostgreSQL. No incident is opened. This lasts up to three times (check frequency + 30 seconds) from creation.
Still no report after thatDown — The agent hasn't reported on PostgreSQL — check it's set up on the server
The agent can't connect to the databaseDown — The agent can't connect to PostgreSQL on localhost:5432
The database stopped reporting, the agent didn'tDown — PostgreSQL on db-01 stopped reporting 95s ago while the agent is still running — PostgreSQL may be down
The agent itself stopped reportingDown — The agent on db-01 hasn't reported for 240s — the server or the agent may be down

A report counts as recent for the monitor's Check frequency plus 30 seconds. With the default of 3 minutes, a database that goes quiet is reported down within about three and a half minutes of its last report.

lightbulb

Because the agent only connects out, a private monitor also catches the server itself going away: when the agent stops reporting, the monitor goes down with the “agent hasn't reported” message.