mirror of
https://github.com/louislam/uptime-kuma.git
synced 2026-03-02 22:57:00 -05:00
Monitor Postgres query result #1575
Labels
No labels
A:accessibility
A:api
A:cert-expiry
A:core
A:dashboard
A:deployment
A:documentation
A:domain expiry
A:incidents
A:maintenance
A:metrics
A:monitor
A:notifications
A:reports
A:settings
A:status-page
A:ui/ux
A:user-management
Stale
ai-slop
blocked
blocked-upstream
bug
cannot-reproduce
dependencies
discussion
duplicate
feature-request
feature-request
good first issue
hacktoberfest
help
help wanted
house keeping
invalid
invalid-format
invalid-format
question
releaseblocker 🚨
security
spam
type:enhance-existing
type:new
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/uptime-kuma#1575
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @thedatabaseme on GitHub (Nov 23, 2022).
⚠️ Please verify that this feature request has NOT been suggested before.
🏷️ Feature Request Type
New Monitor
🔖 Feature description
I would love to see the possibility within Uptime-Kuma, to specify an expected result within a SQL query monitor type (e.g. Postgres).
So a SQL monitor would not only check if it can connect to a database and can execute a query.
Another wish from my side would be, to store the query result in the heartbeat data. You could cut the result to save space, but at least one would have some idea on how the result looked like.
✔️ Solution
I want to check for the replication status of a Postgres cluster and if a specific cluster member is in recovery or not. So a query like
select * from pg_is_in_recovery();would return eithert(true) orf(false). I would like to have the possibility to monitor for the expected result.❓ Alternatives
If you don't consider to implement this request, at least the result should be exported as a metric so that I can filter on it later. Implementing both options, would be the best solution.
📝 Additional Context
No response
@blackandred commented on GitHub (Dec 1, 2022):
Alternatively you can try to use Infracheck with a custom script, expose the endpoint and just ping it using a regular HTTP check in Uptime Kuma.
https://infracheck.docs.riotkit.org/en/latest/
@cfoellmann commented on GitHub (Mar 20, 2023):
I am with @thedatabaseme
I would like to set my SQL statement and define a return value for up (and down).
Or just "0 = down" and "1 = up". Forming the return in your query is easy enough, right?
In my case I would count the rows of a table and return "DOWN" if the count is 0.
@grzywek commented on GitHub (Apr 11, 2023):
Totally for it. Doesn't seem to be very complicated to implement.
@rogerioadris commented on GitHub (Apr 11, 2023):
Is there any condition of the query to return down? or is the query just executed without monitoring the return?
@thedatabaseme commented on GitHub (Apr 11, 2023):
My understanding of the current implementation is, that there is no actual check for the result of the SQL query. When the query finishes without error, the monitor is up. Else it's down.
@rogerioadris commented on GitHub (Apr 11, 2023):
Thanks for the answer.
I solved my problem as follows
@wvolkov commented on GitHub (Mar 20, 2024):
Thx to @rogerioadris idea, I could use it at PostgresSQL as well:
@YuriyGavrilov commented on GitHub (Sep 18, 2024):
+1
What about Trino sql support? can I configure it already or need to support it?
@YuriyGavrilov commented on GitHub (Sep 18, 2024):
Maybe add support sqlalchemy instead of adding db one by one?
Trino does not supported yet (((
@CommanderStorm commented on GitHub (Sep 24, 2024):
sqlalchemy is a python tool, while uptime kuma is written in js
Adding and maintaining monitors for every db out there is indeed unmanagable. I'd prefer to limit ourselves to the popular ones. Since I have not heard of Trino, I don't think this is a good fit.
You can always use the
pushmonitor to push results to UK. This way, arbitrary checks can be performed, including databases without the large support of postgres/..@CommanderStorm commented on GitHub (Nov 6, 2025):
The way we should go about this is to first migrate the pg monitor ot the new structure here:
https://github.com/louislam/uptime-kuma/tree/master/server/monitor-types
After this, adding conditions is very simple (see the dns monitor for details)
@daltonpearson commented on GitHub (Dec 2, 2025):
I've submitted a PR that migrates the pg monitor to the new structure.
@ramonsmits commented on GitHub (Jan 6, 2026):
Just having a check that checks for number of rows in the result set to be either empty or non empty.
I have some queries where I expect rows and other monitoring queries that should NOT return rows.
FYI: THis is my solution for Postgres:
This is similar to the TSQL solution mentioned earlier:
@CommanderStorm commented on GitHub (Jan 6, 2026):
The step from having its own monitor type and supporting conditions properly is not that large.
It is a 3-5 line change as you can see here
I think it is much simpler and does not require any true work. All work has been done, feature just needs to be enabled basically