uptime-kuma icon indicating copy to clipboard operation
uptime-kuma copied to clipboard

Query data of the current status via javascript

Open Skyfay opened this issue 3 years ago • 2 comments

⚠️ Please verify that this bug has NOT been raised before.

  • [X] I checked and didn't find similar issue

🛡️ Security Policy

📝 Describe your problem

Is there a way to query the status of a service via javascript and then execute something? I'm not very familiar with javascript yet, but can someone give me an example of how this could work?

🐻 Uptime-Kuma Version

1.16.0

💻 Operating System and Arch

Ubuntu 20.04

🌐 Browser

Chrome

🐋 Docker Version

No response

🟩 NodeJS Version

No response

Skyfay avatar May 29 '22 13:05 Skyfay

Whilst there is currently no public API you could use the prometheus /metrics file and parse that using JavaScript. In terms of how it would work you would first need to make a get request using the fetch API (https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch). Then you could go about parsing the data and extracting the parts you need. This would probably require a bit of regex and some string manipulation. A quick google search yeilded this node library that you might wish to check out https://github.com/yunyu/parse-prometheus-text-format

Computroniks avatar May 30 '22 00:05 Computroniks

We are clearing up our old issues and your ticket has been open for 3 months with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Sep 12 '22 00:09 github-actions[bot]

This issue was closed because it has been stalled for 7 days with no activity.

github-actions[bot] avatar Sep 19 '22 00:09 github-actions[bot]