Closed Disane87 closed 1 year ago
Can you confirm what version you are installing from HACS?
V2.0.0 should work fine. I'm also using a very similar setup as you. I'm also redirecting all subdomains to Nginxproxymanager which provides a let's encrypt ssl and then redirects the traffic to a docker instance running uptime kuma (with 2fa enabled). I also use Adguard for my DNS with rewrites (sounds like we have a VERY similar setup!) Make sure you are entering https:// in the url and just use your normal username and password (no special app password needed). It seems like the uptime kuma api doesn't require the 2fa code or an app password currently. Port should be 443 if you're using ssl.
If you're following the above, then I suppose DNS would be the next culprit.
Maybe double check your https://
url. The error you copied seems to indicate that you're trying to use http>
or something similar?
Can you confirm what version you are installing from HACS?
I added your repo to HACS as custom repo, so I guess this will be v2.
Maybe double check your
https://
url. The error you copied seems to indicate that you're trying to usehttp>
or something similar?
This is not http>
in the error, it's:
could not convert string to float: 'html>'
It seems like the uptime kuma api doesn't require the 2fa code or an app password currently.
Yeah thats right @meichthys, looks like the /metrics
endpoint of uptime kuma only uses the basic auth without 2FA, which is totally fine because you can't change anything.
Furthermore, I did a cURL to the metrics endpint of my uptime kuma subdomain from my HA docker with host network which resulted in this response:
<html>
<head><title>302 Found</title></head>
<body>
<center><h1>302 Found</h1></center>
<hr><center>nginx</center>
</body>
</html>
I had expected that there is this kind of response:
# HELP monitor_cert_days_remaining The number of days remaining until the certificate expires
# TYPE monitor_cert_days_remaining gauge
[ ... ]
I guess your code doesn't handle the 302 HTTP code not properly? That would explain why it's working with the IP.
The strange thing is, I had to use the --insecure
flag for my cURL request because without it, the request failed with curl: (60) SSL certificate problem: self signed certificate
even when it's a SSL cert from LE.
Did you added your subdomains to the DNS rewrites in AdGuard like this?
traceroute
resolved properly to my unraid server, so I guess this isn't really a problem of my DNS.
But the config of my reverse proxy looks good imho:
So this issue is pretty weird. Especially while it's working with the IP and port I used for my uptime kuma docker with bridged network:
So the problem seems to be in the DNS and/or Proxy but the configs seem to ok.
I'm not sure what else to try, but yes, I do have my Adguard rewrites setup the same 👍
I have my uptime kuma accessible publicly, so that is a difference. My guess is still something with dns.
Are you running traceroute from your homeassistant box? That's the machine that needs to be able to resolve uptime kuma.
I have my uptime kuma accessible publicly, so that is a difference. My guess is still something with dns.
Mine is public too 🙂
Are you running traceroute from your homeassistant box? That's the machine that needs to be able to resolve uptime kuma.
Yeah I tried this from the HA machine.
What I can check is: You use the external dep UptimeKuma to connect. I could write something similar only to and check the connection from different machines, so I know if it's the machine or something else. Since I know python this shouldn't be a problem.
Maybe you have your internal network setup differently, but you may want your Access List in Nginxproxymanager to be set to public?
Maybe you have your internal network setup differently, but you may want your Access List in Nginxproxymanager to be set to public?
Already tried this, nothing changed
Are you using vlans in your setup? Or does homeassistant have multiple network adapters?
No, none of this. I don't have any vlan nor does HA has more than one network
Same fault for me. Uptime Kuma in Kubernetes behind proxy (Traefik). Works fine in a browser and with curl using http://host:80/metrics Let me know if I can help with more info!
@jayakornk any ideas here? Seems to be related to the new pyuptimekuma dependency.
Same fault for me. Uptime Kuma in Kubernetes behind proxy (Traefik). Works fine in a browser and with curl using http://host:80/metrics
Let me know if I can help with more info!
Thank you for reporting this! Actually I guess the problem is the reverse proxy and the redirect.
I hope I can test the dependency for uptime kuma in a blank new project to test how this can be solved.
Had the chance to test this with the example script of https://github.com/jayakornk/pyuptimekuma
This even crashes with the same error:
could not convert string to float: 'html>'
During handling of the above exception, another exception occurred:
File "C:\Users\Disane\OneDrive\Desktop\uptime-kuma-proxy.py", line 17, in main
response = await uptime_robot_api.async_get_monitors()
File "C:\Users\Disane\OneDrive\Desktop\uptime-kuma-proxy.py", line 22, in <module>
loop.run_until_complete(main())
I guess this is a problem of the package pyuptimekuma
@meichthys I've setup a test instance of uptime kuma in my infrastructure (with the same proxy and such things lile my prod instance) so you can test this behavior:
Host: https://uptime-kuma-proxy.disane.dev/
User: TestProxy
PW: TestProxy
Thie exception is the same in that instance:
Code:
import asyncio
import aiohttp
from pyuptimekuma import UptimeKuma
URL = "https://uptime-kuma-proxy.disane.dev/"
USERNAME = "TestProxy"
PASSWORD = "TestProxy"
VERIFY_SSL = False
async def main():
async with aiohttp.ClientSession() as session:
uptime_robot_api = UptimeKuma(
session, URL, USERNAME, PASSWORD, VERIFY_SSL)
response = await uptime_robot_api.async_get_monitors()
print(response.data)
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
Feel free to reach out to me if you need something.
@Disane87 Thanks for setting up the test instance. It probably doesn't help you find out what's happening on your end, but your test instance works fine in my HomeAssistant: 🤷♂️
Thank you for the test! In my networks this fails, so the only thing which is differing from internal and external call is the AdGuard DNS.
Yes it does seem like it is dns related. Either in Adguard or in homeassistant.
I am having the exact same error too:
could not convert string to float: 'html>'
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/prometheus_client/parser.py", line 114, in _parse_sample
label_start, label_end = text.index("{"), text.rindex("}")
ValueError: substring not found
I also get the same error:
2022-11-26 22:39:42.487 ERROR (MainThread) [custom_components.uptime_kuma] Request exception for '192.168.1.4:3001/metrics' with - 192.168.1.4:3001/metrics
Unt-icked verify SSL and it was using http locally.
When I use external URL with SSL, it went through fine.
@dougmaitelli Please check your dns configuration.
Since others have this problem too:
I've fixed my issue. It was a problem of DNS and my infrastructure.
All my incoming traffic of port 443 is forwarded to my NPM which routes per domain binding to the appropiate services. This worked perfectly but I saw, the pings from the internal network to my domains (which are set in NPM) went out and than over my public IP back in and that was totally crap.
I thought the dns rewrites would fix this, but they made it much worse because they pointed to my internal unraid which listend to port 80/443 and on this was the self signed cert and not the /metrics
endpoint. Instead this the response was my unraid ui.
NPM runs on that unraid as bridge with an own IP on port 4443 and 8080. To forward all my internal 80/443 on the domains I've created a stream host which maps port 443 to 4443 which is now handled by the proxy itself.
I this helps others :)
Thanks for following up!
Hi, thank for this project! But I have encountered a pretty weird bug. When I set up the integration, the settings dialog provides me this error:
I already checked the credentials, the url (with/without protocol and port etc.) but it won't work. I even disabled the 2FA in Uptime Kuma and changed my password, as mentioned in #10.
I saw an error in the homeassistant logs:
I guess this could be a problem by my dns, because I redirect every call to my subdomains '*.disane.dev' to my local reverse proxy (Nginx proxy manager) which provides the SSL.
All right, I thought to myself. I just take the IP address. and that works. So I guess that problems could result from my dns. But when I browse to my subdomain for uptime kuma, it works flawlessless.
As a DNS I use AdGuard home and some DNS redirects. Do you have any idead how I could solve this?