Skip to content
Upstat

Database monitoring

A database is usually not reachable from the internet, and it should not be. That is why the check is done by the Connect agent inside your network. Upstat tells it which database to try, and the agent returns whether it answers and how fast.

Create an account and watch your services

Database monitor: connect, a simple query and latency through the Upstat Connect agent.

The Upstat Connect agent runs in your network next to the database. It connects to the database of the type you set, checks that it answers and measures the latency. Credentials stay stored in the agent. The agent sends the result to Upstat.

What is checked

  1. The Connect agent runs in your network and keeps a connection to Upstat. The agent opens the connection, so you do not have to expose the database.
  2. On every check Upstat sends the agent the database type and the name of a connection from the agent configuration. Upstat never receives the password or the database address, they stay with the agent.
  3. The agent connects, verifies the database answers and returns whether it is reachable, the measured latency and the server version.
  4. The check passes if the database is reachable. The latency is stored with the result.

Supported databases

The agent supports five database types. For each it makes a simple connection and ping and reads the server version.

PostgreSQL postgres
Connect and run SELECT 1. The version comes from SHOW server_version.
MySQL and MariaDB mysql
Connect and run SELECT 1. The version comes from SELECT VERSION().
Redis redis
Connect and send PING. The version comes from INFO server (redis_version).
MongoDB mongodb
Connect and run the ping command. The version comes from buildInfo.
Oracle oracle
Connect and run SELECT 1 FROM DUAL. The agent host needs the Oracle Instant Client libraries, the agent loads them at runtime. If they are missing it returns a clear error.

How to set it up

  1. In the dashboard open Connect agents and create a target. The agent key is shown only once, copy it.
  2. The dashboard shows the agent configuration together with the key. The agent is built from the sk.upstat.connect repository and runs inside your network.
  3. In the agent configuration name each connection, give its type and DSN (inline or through an environment variable). The password stays with the agent.
  4. Once the agent logs in, the target shows as online in the dashboard.
  5. Create a Database monitor: choose the target, the database type and the connection name from the agent configuration.

Example agent configuration

The agent reads a configuration file with named connections. You enter the connection name (main-db here) in the monitor. The agent key is read from the environment variable whose name is set in auth_key_env.

Agent configuration

daemon_url = "wss://connect.upstat.sk"
target_id = "01J..."
auth_key_env = "UPSTAT_CONNECT_KEY"

[connections.main-db]
type = "postgres"
dsn_env = "MAIN_DB_DSN"

Monitor settings

This is the configuration shape the checker reads. The monitor is also bound to one specific Connect agent.

Connect target connect_target_id

The agent that performs the check. You pick it from your own Connect targets.

Where to set it: Dashboard, through the Connect agent

Database type db_type

PostgreSQL, MySQL (also MariaDB), Redis, MongoDB or Oracle. The type is passed to the agent and must match the connection type in the agent configuration.

Where to set it: Dashboard, through the Connect agent

Connection name dsn_ref

The name of a connection from the agent configuration. Upstat never receives the credentials themselves.

Where to set it: Dashboard, through the Connect agent

Timeout timeout_ms

An optional longest time in milliseconds the agent waits for the database.

Where to set it: Dashboard, through the Connect agent

What counts as a failure

  • The agent reached the database over the network, but the database refused or failed the ping.
  • The agent is not connected. The check then fails with an agent-unavailable error.
  • The agent returns an error, for example for an unknown connection name, a type that does not match the agent configuration, or missing Oracle Instant Client libraries.

What happens on failure

  • The monitor changes from UP to DOWN. If you use ignore blips, the failure first has to last for the time or the number of checks you set.
  • An incident named after the monitor is created automatically. When a check passes again, the incident closes itself.
  • Your alert rules send a message through the channels you set up: Slack, Discord, Telegram, email, SMS, push, webhook or ntfy.
  • If the monitor is linked to a status page component, its state shows up there too.

How it works with ignore blips

A short outage does not have to mean DOWN right away. For each monitor you can set state stabilization. Upstat decides it when it processes check results, not the checker.

consecutive_failures
How many checks in a row must fail before the monitor is marked DOWN. For example 3 means three failures in a row.
min_down_seconds
How long the failing has to last before the state changes to DOWN.
min_up_seconds
How long everything has to be fine after an outage before the monitor goes back to UP. It protects against rapid flapping.

A database can stop responding for a moment during a backup, failover or restart. A few failures in a row separate a real outage from planned maintenance.

How monitoring works

Limits by plan

The shortest allowed interval between checks depends on the plan. The numbers are read straight from the plan settings.

Plan Shortest check interval
Hobby 120 s
Starter 60 s
Pro 30 s