MySQL / MariaDB Query
Run your own SELECT query on a MySQL or MariaDB server and get alerted on its row count or execution time.
The MySQL / MariaDB Query check runs your own SQL query on a MySQL or MariaDB server and evaluates either the number of rows returned or the execution time. Use it, for example, to watch for stuck orders, failed jobs or slow queries. The check runs on the agent device you assign it to and connects from there over TCP to the host you enter. It runs on Windows, Linux and macOS (each in x64 and Arm64), every 5 minutes by default. The database server itself does not need to be an agent device; any agent device that can reach it over the network is enough.
Prerequisites
- An account on the database server that may sign in from the agent device's address. To create the monitoring account, see Set up the database monitoring account.
SELECTrights on exactly the tables your query reads.
Steps
- Go to Devices and open the device.
- Click the Checks tab → Add Check → MySQL / MariaDB Query.
Settings
The check counts rows, not values. SELECT count(*) FROM orders WHERE status = 'stuck' always returns exactly one row and is therefore always evaluated as 1, no matter how many entries are affected. Write the query so that it returns one row per problem, for example SELECT id FROM orders WHERE status = 'stuck'.
Results
The check compares the chosen value (row count or execution time) with both thresholds. Thresholds also trigger on equality.
With the defaults (both thresholds 1, mode Row count), the check is therefore Critical as soon as the query returns at least one row, and OK otherwise. If the two thresholds are in the wrong order, the check swaps them before evaluation. Connection setup and query have a fixed 15-second timeout.
Metrics collected
- Number of rows returned
- Query execution time in milliseconds (excluding connection setup)
Notes
- Setting the session to
READ ONLYis a safety net, not a replacement for a read-only account. Grant the monitoring accountSELECTonly. - The host is part of the check configuration. If you assign the check to many devices through a config package, each of them runs the same query against the same server. Assign it to a single device instead.
Was this helpful?
More in Databases & applications
Set up the database monitoring accountDATEVDFSR BacklogDHCP Scope UtilizationStill need help? Ask the team