meichthys / uptime_kuma

Uptime Kuma HACS integration
110 stars 23 forks source link

Unexpected error, first installation #55

Closed kaciker closed 1 year ago

kaciker commented 1 year ago

Hello

I tried I think that all posibilities to make work the integration.... I'm a little frustrated 📦 I installed Kuma as addon in HassOS I installed Kuma as doker in another server in same network than HAssOS I tried to connect bi Ip, port, http Also I tried with NPM (in docker version, where can acces without problems) I tied in two HAssOS deployments, in different servers, bu same network

I all cases, I revceive Unexpected error.

I don't really know what to do

image

meichthys commented 1 year ago

Can you ping the hasos machine from the kuma machine? Are you using SSL? You must use a valid cert - I don't think self signed certs will work.

meichthys commented 1 year ago

This also may help: https://github.com/meichthys/uptime_kuma/issues/23

meichthys commented 1 year ago

https://github.com/meichthys/uptime_kuma/issues/33#issuecomment-1482738545

kaciker commented 1 year ago

Can you ping the hasos machine from the kuma machine? Are you using SSL? You must use a valid cert - I don't think self signed certs will work.

Hi Thanks for answer

Yes, I can ping HAssos (two instances) from kuma in docker Also I set a NPM proxy host, where the cer is valid. IS not a self signed.

image

meichthys commented 1 year ago

Do you have kuma api turned on? This integration will not work with the api turned on

meichthys commented 1 year ago

Could you provide the Hassos logs showing the error?

kaciker commented 1 year ago

Could you provide the Hassos logs showing the error?

HI, This is the only that I see 023-06-18 21:42:33.876 ERROR (MainThread) [custom_components.uptime_kuma] could not convert string to float: 'html>' Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/prometheus_client/parser.py", line 122, in _parse_sample label_start, label_end = text.index("{"), text.rindex("}") ^^^^^^^^^^^^^^^ ValueError: substring not found During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/config/custom_components/uptime_kuma/config_flow.py", line 58, in _validate_input await uptime_robot_api.async_get_monitors() File "/usr/local/lib/python3.11/site-packages/pyuptimekuma/decorator.py", line 68, in wrapper response = UptimeKumaApiResponse.from_prometheus( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pyuptimekuma/models.py", line 76, in from_prometheus for family in parsed: File "/usr/local/lib/python3.11/site-packages/prometheus_client/parser.py", line 22, in text_string_to_metric_families for metric_family in text_fd_to_metric_families(StringIO.StringIO(text)): File "/usr/local/lib/python3.11/site-packages/prometheus_client/parser.py", line 217, in text_fd_to_metric_families sample = _parse_sample(line) ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/prometheus_client/parser.py", line 140, in _parse_sample value = float(_parse_value(text[name_end:])) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

kaciker commented 1 year ago

Do you have kuma api turned on? This integration will not work with the api turned on

I really don't know how to activate that.. so I think that I din't activate

meichthys commented 1 year ago

Hmm I'm not sure what's going on there. It seems to be working for me. I would try disabling one of the kuma instances and double check that api access is disabled in kuma and that your credentials are correct.

You can also make sure that you are able to access the '/metrics' endpoint on your kuma instance (that's where the data comes from).

kaciker commented 1 year ago

/metrics

I arrive to https://mydns/metrics but the same credentials that I set to enter in Kuma, does not works to this log -in. is this notmal ?

meichthys commented 1 year ago

No that is not normal. This is your issue. You need to be able to access the metrics endpoint. Check your credentials. Usually this issue is caused by the uptimekumma api being turned on.

meichthys commented 1 year ago

No that is not normal. This is your issue. You need to be able to access the metrics endpoint. Check your credentials. Usually this issue is caused the the uptimekumma api being turned on. maybe try changing your credential in case there is a special character that is causing some weirdness.

kaciker commented 1 year ago

No that is not normal. This is your issue. You need to be able to access the metrics endpoint. Check your credentials. Usually this issue is caused by the uptimekumma api being turned on.

Where this API is activetad/unactivated ? I disabled the autentification and works ¡¡ image

meichthys commented 1 year ago

Just make sure you have no api keys Screenshot_20230618-163521.png

OptimusGREEN commented 1 year ago

I think I'm getting the same issue.


Logger: custom_components.uptime_kuma
Source: custom_components/uptime_kuma/config_flow.py:58
Integration: Uptime Kuma (documentation, issues)
First occurred: 23:40:49 (3 occurrences)
Last logged: 23:46:43

could not convert string to float: 'html>'
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/prometheus_client/parser.py", line 122, in _parse_sample
    label_start, label_end = text.index("{"), text.rindex("}")
                             ^^^^^^^^^^^^^^^
ValueError: substring not found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/uptime_kuma/config_flow.py", line 58, in _validate_input
    await uptime_robot_api.async_get_monitors()
  File "/usr/local/lib/python3.11/site-packages/pyuptimekuma/decorator.py", line 68, in wrapper
    response = UptimeKumaApiResponse.from_prometheus(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyuptimekuma/models.py", line 76, in from_prometheus
    for family in parsed:
  File "/usr/local/lib/python3.11/site-packages/prometheus_client/parser.py", line 22, in text_string_to_metric_families
    for metric_family in text_fd_to_metric_families(StringIO.StringIO(text)):
  File "/usr/local/lib/python3.11/site-packages/prometheus_client/parser.py", line 217, in text_fd_to_metric_families
    sample = _parse_sample(line)
             ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/prometheus_client/parser.py", line 140, in _parse_sample
    value = float(_parse_value(text[name_end:]))
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: could not convert string to float: 'html>'

i can access the metrics endpoint using same credentials though.

meichthys commented 1 year ago

Make sure you are on the latest HA version. There was an issue with older versions of HA earlier this year.

meichthys commented 1 year ago

Checklist:

Hopefully this helps.

kaciker commented 1 year ago

Checklist:

  • [ x] Ensure you are using the latest version of HA

Home Assistant 2023.6.2 Supervisor 2023.06.2 Operating System 10.2 Frontend 20230608.0 - lates

  • [x ] Ensure you are using a recent version of UptimeKuma (I haven't tested with the latest version) Uptime Kuma Versión: 1.21.3 Versión de Interfaz: 1.21.3

  • [ x] Ensure you do not have any uptimekuma api keys setup

image
  • [x ] Ensure you are using a valid certificate (not self-signed)

Cert it is OK

  • [ x] Ensure your credentials are correct (or turn off credentials)

turned off: workd turnoed on: KO

  • [ ko] Ensure your /metrics endpoint is accessible using the credentials you've setup not accesible with atentification = On without auth. Not working

Hopefully this helps.

Thanks for the support. rightnow I will work without and in IP not DNS mode

jorgemontes commented 1 year ago

Have the same issue. It does not work if you have the Auth enabled. Otherwise I will always get a 401 as response. I think the way to authenticate to the API now is using a API Token instead of user auth.

meichthys commented 1 year ago

I have auth enabled and it's working as expected. AFAIK, using an API token will not work.

meichthys commented 1 year ago

see here: https://github.com/meichthys/uptime_kuma/issues/55#issuecomment-1596340832 if you cannot access <your_uptimekuma_url>/metrics endpoint, then homeassistant will not be able to access it either.

mattdevo1 commented 1 year ago

I'm running the latest versions of Home Assitant (2023.7) and Uptime Kuma (1.22.1), and I can't get this integration to work without disabling auth.

meichthys commented 1 year ago

@mattdevo1 Can you access the '\metrics' endpoint of your uptimekjma with your credentials? If not, then its an issue with your uptime kuma config or your reverse proxy or something in between.

mattdevo1 commented 1 year ago

@mattdevo1 Can you access the '\metrics' endpoint of your uptimekjma with your credentials? If not, then its an issue with your uptime kuma config or your reverse proxy or something in between.

Yes I can.

And there is no proxy or anything else between HA and Uptime Kuma.

meichthys commented 1 year ago

Are you using the homeassistant uptimekuma add-on?

mattdevo1 commented 1 year ago

Are you using the homeassistant uptimekuma add-on?

No. Running Uptime Kuma on a separate docker host.

meichthys commented 1 year ago

Can you fetch the metrics endpoint from the homeassistant machine? Using something like https://community.home-assistant.io/t/home-assistant-add-on-firefox/558672

mattdevo1 commented 1 year ago

Can you fetch the metrics endpoint from the homeassistant machine? Using something like https://community.home-assistant.io/t/home-assistant-add-on-firefox/558672

Yes, that worked fine, with auth enabled.

After I tested that, I deleted the Uptime Kuma integration and added it again with auth still enabled in Uptime Kuma. Aaaaaand it magically worked!

No idea what was going on (which annoys me), but everything seems to be working now. Sorry to have wasted your time, but thanks for your troubleshooting help!

meichthys commented 1 year ago

No problem. Glad it worked.

mattdevo1 commented 1 year ago

@meichthys - Sorry this won't be super helpful for troubleshooting, but my Uptime Kumar sensors became unavailable. I disabled auth in Uptime Kuma and re-added the integration and everything came back online again.

I don't have time to troubleshoot further unfortunately (disabling Auth is a fine workaround for me), but there might still be an issue here.

livehybrid commented 1 year ago

Incase anyone else has this issue, I found that creating an API key and using "admin" as the username and the API key as the password in the HA setup workflow worked for me :)

alchemydc commented 6 months ago

For those of you struggling with getting this integration to work with https and api keys, here is what works for me:

1) Specify your kuma host as https://$your_hostname.domain Do NOT add a trailing slash, or the integration will break with an unexpected error in the UI, and an ValueError: could not convert string to float: 'html>' error in the log. 2) Username: admin 3) Password: $your_api_key

kaciker commented 6 months ago

For those of you struggling with getting this integration to work with https and api keys, here is what works for me:

  1. Specify your kuma host as https://$your_hostname.domain Do NOT add a trailing slash, or the integration will break with an unexpected error in the UI, and an ValueError: could not convert string to float: 'html>' error in the log.
  2. Username: admin
  3. Password: $your_api_key

This works for me ¡¡¡¡ finally I could come back to secure ¡¡ Thanks (only my user is not admin :P "