Have a JSON Endpoint for polling of metrics (Home Assistant) #197

Closed
opened 2026-02-28 01:38:20 -05:00 by deekerman · 2 comments
Owner

Originally created by @iotemylabs on GitHub (Sep 6, 2021).

Hi!

I really love Uptime-Kuma, I just deployed this on my home and office servers!

I wanted to get metrics like the Prometheus endpoint as a JSON endpoint so I can port info direct to home assistant :)

Thank you!

Originally created by @iotemylabs on GitHub (Sep 6, 2021). Hi! I really love Uptime-Kuma, I just deployed this on my home and office servers! I wanted to get metrics like the Prometheus endpoint as a JSON endpoint so I can port info direct to home assistant :) Thank you!
Author
Owner

@louislam commented on GitHub (Sep 6, 2021):

Duplicate of #118

@louislam commented on GitHub (Sep 6, 2021): Duplicate of #118
Author
Owner

@hendrikma commented on GitHub (Sep 18, 2021):

I came a long with an other solution to this topic since there are only Notifications available when there is some service down but not for monitoring the status:

sensor:
  - platform: command_line
    name: Uptime Kuma Test
    command: curl -s -u <YOUR_USER>:<YOUR_PASSWORD> http://<YOUR_IP>:3001/metrics | grep -Poi '^monitor_response_time{.*?} \d+$'
    unit_of_measurement: "ms"
    value_template: >-
      {{ value | regex_findall_index(find="monitor_type=\"<TYPE>\".*monitor_hostname=\"<ESCAPED_HOSTNAME>\".*} (\d*)", index=0, ignorecase=False) }}

Thats for getting the Response-Time for a Hostname. You have to escape the hostname correctly like so
my.hostname.to.monitor > my.hostname.to.monitor

Have fun with it ;)
PS Ofcourse to monitor the Ping to a service/server you can just use the Ping-Sensor 😄

@hendrikma commented on GitHub (Sep 18, 2021): I came a long with an other solution to this topic since there are only Notifications available when there is some service down but not for monitoring the status: ``` sensor: - platform: command_line name: Uptime Kuma Test command: curl -s -u <YOUR_USER>:<YOUR_PASSWORD> http://<YOUR_IP>:3001/metrics | grep -Poi '^monitor_response_time{.*?} \d+$' unit_of_measurement: "ms" value_template: >- {{ value | regex_findall_index(find="monitor_type=\"<TYPE>\".*monitor_hostname=\"<ESCAPED_HOSTNAME>\".*} (\d*)", index=0, ignorecase=False) }} ``` Thats for getting the Response-Time for a Hostname. You have to escape the hostname correctly like so my.hostname.to.monitor > my\.hostname\.to\.monitor Have fun with it ;) PS Ofcourse to monitor the Ping to a service/server you can just use the [Ping-Sensor](https://www.home-assistant.io/integrations/ping) 😄
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/uptime-kuma#197
No description provided.