Monitoring Pi-hole for uptime with Uptime Kuma

anyone have any tips to integrate Pihole into Uptime Kuma monitoring? I could have it look for a keyword on the pihole status webpage, but it wouldn't be able to tell me if Pihole is logged in or not (because the admin login expires every 7 days), and it would just show me if it was serving a webpage or not.

If you want to know if Pi-hole is working, don't monitor the web admin GUI. Just look at pihole status or make a DNS query to Pi-hole.

You don't need to access the dashboard page to know Pi-hole status.

You can use an API call to know that:

http://pi.hole/admin/api.php?status&auth=<YOUR_API_TOKEN>

If Pi-hole is running it will return enabled or disabled, depending on the block status. If Pi-hole is not running the call will fail.

1 Like

this is amazingly easy. Thank you.

Anyone if something similar is possible with pihole v6? Reviewing the API docs not sure what the best way is, or if even possible.....

I am having the same issue. Upgraded to V6 but now Uptime Kuma is showing down. Not sure what to point it to. Also am a real novice at this so I have no idea what to be looking for in the API.

I don't know. I switched to paying yearly for nextdns so I don't run a pihole anymore.

I did figure this out. Unfortunately, while a solution is doable, its not a single line like the old version. If you're a complete novice, you'll probably want to read up on REST APIs in general. You need to retrieve a session ID (SID), then use the SID to access the desired API endpoint, then end the session (so not to end up with too many open API sessions). There are various ways this is possible, but not directly. I ended up created a flow in Node Red to facilitate this. You could also setup a node.js server. The API authentication documention is here: Authentication - Pi-hole documentation

If you're wanting to monitor whether DNS resolution is working, it makes sense to actually test DNS resolution rather than querying the API. Under the hood, DNS and API are probably separate processes that could possibly be in different states. Uptime Kuma has a DNS monitor type, so you can configure a monitor like:

Monitor Type: DNS
Hostname: www.server.com # (hostname to resolve)
Resolver Server: 192.168.1.2 # (your pi-hole IP address)
Port: 53
Resource Record Type: A # (might vary based on the hostname you want to resolve)
2 Likes

This is the best way because it avoids any API calls. I have been doing this for about 2 years with Pi-Hole5, and it has performed flawlessly.