medaziz11 / uptime-kuma-web-api Goto Github PK
View Code? Open in Web Editor NEWUptime Kuma REST API
Uptime Kuma REST API
Hosted:
Docker Instance
Objective:
Serve API-Outputs to a Website written in PHP.
Problem:
Despite the ACCESS_TOKEN_EXPIRE variable being set to 8-days. My tokens seem to be expiring after every API call. Which leads me to believe a bug exists.
Can I reproduce?
Yes, I'm able to re-produce every other API call. Literally.
Proposed Solution:
Either remove the tokens all together, or allow the option to /opt-out/ or even set a static Bearer through the UI on the hosted port. Given these end-points rarely contain sensitive data - it's worth while reviewing the approach re:security for this project. As, it's become a hindrance to the objective.
First of all, nice work! Thanks!
But currently it is not possible to assign tags to a monitor or is it possible?
Cant find any tag key in the monitor schema API for that ;(
It seems that there is a compatibility issue with the version. My api version is 1.2.2 and the uptime-kuma version is 1.23.11. Restoring a backup via API is ending into an error:
"SQLITE_CONSTRAINT: NOT NULL constraint failed: monitor.invert_keyword"
The invert_keyword has a value of "false" and not NULL, but it seems that when it tried to insert it to the db, it is not getting the "false" value, but "null" instead.
Backup is working from kuma version 1.21.3. Haven't tested yet with other version.
Getting "Invalid HTTP request received" in the backend service logs after trying the curl command to get the access token. Tried debugging the auth route file but I cannot get any log message past the initial router file include ๐ค would seems as if something fails from the very moment of the POST request. I can open the docs just fine ๐ค . Thanks for this great repo!
I have a kuma instance running already and i need to install the api container but i am not so proficient with docker.
I am not using docker compose so i would appreciate it if somebody pointed me to the right direction about making the api work.
Thank you.
p.s. Can i run it in Raspberry?
I installed it without docker and it runs just fine. In swagger i get Error 401 although i have setup the env vars.
Note that my admin username is not admin.
Hey,
When trying to using the /ping/ endpoint the api only shows the 24 hours average ping for monitor with id number #1.
[{"id":"1","data":180}]
This doesn't seem right.
I just tried out the API and it works fine so far. Thank you for taking the time to build that API wrapper.
When doing the first API calls, I experienced issues with the specified paths. When I call the /monitors
endpoint for example, the authorization is discarded because the API returns a 307 response and redirects to /monitors/
with the trailing slash.
Setting the path explicitly with the trailing slash fixes the issue. But it's a weird issue and I expected the API to work with regular paths.
Is it possible to let the app listen on both /monitors/
and /monitors
instead of redirecting from one or the other?
Hello
want to retest #62 with an RPi and Bookworm as docker host OS. But the startup of the image medaziz11/uptimekuma_restapi leads to this errors:
pi@hadersdorf:~/Uptime-Kuma $ docker-compose logs uptime-api
uptime-api | [2024-01-03 12:29:39 +0100] [1] [INFO] Starting gunicorn 20.1.0
uptime-api | [2024-01-03 12:29:39 +0100] [1] [INFO] Listening at: http://0.0.0.0:8000 (1)
uptime-api | [2024-01-03 12:29:39 +0100] [1] [INFO] Using worker: uvicorn.workers.UvicornWorker
uptime-api | [2024-01-03 12:29:40 +0100] [7] [INFO] Booting worker with pid: 7
uptime-api | [2024-01-03 12:29:45 +0100] [7] [INFO] Started server process [7]
uptime-api | [2024-01-03 12:29:45 +0100] [7] [INFO] Waiting for application startup.
uptime-api | [2024-01-03 12:29:45 +0100] [7] [ERROR] Traceback (most recent call last):
uptime-api | File "/app/venv/lib/python3.9/site-packages/tortoise/backends/sqlite/client.py", line 34, in translate_exceptions_
uptime-api | return await func(self, query, *args)
uptime-api | File "/app/venv/lib/python3.9/site-packages/tortoise/backends/sqlite/client.py", line 153, in execute_script
uptime-api | async with self.acquire_connection() as connection:
uptime-api | File "/app/venv/lib/python3.9/site-packages/tortoise/backends/base/client.py", line 220, in __aenter__
uptime-api | await self.ensure_connection()
uptime-api | File "/app/venv/lib/python3.9/site-packages/tortoise/backends/base/client.py", line 216, in ensure_connection
uptime-api | await self.client.create_connection(with_db=True)
uptime-api | File "/app/venv/lib/python3.9/site-packages/tortoise/backends/sqlite/client.py", line 69, in create_connection
uptime-api | await self._connection._connect()
uptime-api | File "/app/venv/lib/python3.9/site-packages/aiosqlite/core.py", line 137, in _connect
uptime-api | self._connection = await future
uptime-api | File "/app/venv/lib/python3.9/site-packages/aiosqlite/core.py", line 102, in run
uptime-api | result = function()
uptime-api | File "/app/venv/lib/python3.9/site-packages/aiosqlite/core.py", line 397, in connector
uptime-api | return sqlite3.connect(loc, **kwargs)
uptime-api | sqlite3.OperationalError: unable to open database file
uptime-api |
uptime-api | During handling of the above exception, another exception occurred:
uptime-api |
uptime-api | Traceback (most recent call last):
uptime-api | File "/app/venv/lib/python3.9/site-packages/starlette/routing.py", line 645, in lifespan
uptime-api | async with self.lifespan_context(app):
uptime-api | File "/app/venv/lib/python3.9/site-packages/starlette/routing.py", line 540, in __aenter__
uptime-api | await self._router.startup()
uptime-api | File "/app/venv/lib/python3.9/site-packages/starlette/routing.py", line 622, in startup
uptime-api | await handler()
uptime-api | File "/app/main.py", line 41, in startup_event
uptime-api | await initialize_app(app)
uptime-api | File "/app/app_setup.py", line 10, in initialize_app
uptime-api | await setup_database()
uptime-api | File "/app/app_setup.py", line 29, in setup_database
uptime-api | await Tortoise.generate_schemas()
uptime-api | File "/app/venv/lib/python3.9/site-packages/tortoise/__init__.py", line 636, in generate_schemas
uptime-api | await generate_schema_for_client(connection, safe)
uptime-api | File "/app/venv/lib/python3.9/site-packages/tortoise/utils.py", line 31, in generate_schema_for_client
uptime-api | await generator.generate_from_string(schema)
uptime-api | File "/app/venv/lib/python3.9/site-packages/tortoise/backends/base/schema_generator.py", line 448, in generate_from_string
uptime-api | await self.client.execute_script(creation_string)
uptime-api | File "/app/venv/lib/python3.9/site-packages/tortoise/backends/sqlite/client.py", line 36, in translate_exceptions_
uptime-api | raise OperationalError(exc)
uptime-api | tortoise.exceptions.OperationalError: unable to open database file
uptime-api |
uptime-api | [2024-01-03 12:29:45 +0100] [7] [ERROR] Application startup failed. Exiting.
uptime-api | [2024-01-03 12:29:45 +0100] [7] [INFO] Worker exiting (pid: 7)
Any idea? Thanks!
Hello,
I use SSO at home and i have disable Uptime Kuma auth.
How to use this RestAPI without auth ?
I try with this config:
KUMA_SERVER: "uptime-kuma.uptime-kuma"
KUMA_USERNAME: ""
KUMA_PASSWORD: ""
ADMIN_PASSWORD: ""
but i have :
{
"detail": "Not authenticated"
}
Thx :)
I have the interface of casaOS
I have created the file docker-compose.yml
with these parameters
`version: "3.9"
services:
kuma:
container_name: uptime-kuma
image: louislam/uptime-kuma:latest
ports:
- "3001:3001"
restart: always
volumes:
- uptime-kuma:/app/data
api:
container_name: backend
image: medaziz11/uptimekuma_restapi
volumes:
- ./db:/db:rwx
restart: always
environment:
- KUMA_SERVER=http://kuma:3001
- KUMA_USERNAME=test
- KUMA_PASSWORD=123test.
- ADMIN_PASSWORD=admin
depends_on:
- kuma
ports:
- "8000:8000"
volumes:
uptime-kuma:`
But when I put the command " sudo docker compose up"
I get this error
ERROR: In file './docker-compose.yml', service must be a mapping, not a NoneType.
Hi, firstly thanks for your work on this, just what I have been looking for. I want to use this to integrate Kuma with my Home Assistant image, to have HA pause and resume monitoring on devices it is turning on/off during the day. Unfortunately my HA instance is on 32 bit OS (as I suspect are quite a lot as they are running on early raspberry pis) and the docker compose fails when trying to add your image.
Thanks,
Hi everyone, I find myself needing to manage personalized notifications for each monitor. Will the ability to create notifications and edit them be implemented? or do you have any suggestions for making it happen?
Thank you
I have setup a few groups for monitors, groups are in fact same monitors records but use the parent field for showing dependances. When posting with curl, seems like this field is ignored. Curl example:
this field is used when i try to get list of monitors with curl:
curl -X 'GET'
'http://10.0.0.17:3002/monitors'
-H 'accept: application/json'
-H 'Content-Type: application/json'
-H "Authorization: Bearer ${TOKEN}"
"parent": 14,
I tried use different combinations: group, monitor_group, group_id, but none of those are working, in web api this is missed
curl -X 'POST'
'http://10.0.0.17:3002/monitors/'
-H 'accept: application/json'
-H 'Content-Type: application/json'
-H "Authorization: Bearer ${TOKEN}"
-d '{
"type": "http",
"name": "example.co.uk",
"pathName": "My group name / example.co.uk",
"parent": 14,
"interval": 120,
"retryInterval": 120,
"resendInterval": 20,
"maxretries": 3,
"upsideDown": false,
"notificationIDList": [
"1"
],
"url": "https://www.example.co.uk",
"expiryNotification": true,
"ignoreTls": false,
"maxredirects": 10,
"accepted_statuscodes": [
"200-299"
],
"includeSensitiveData": true,
"port": 53,
"dns_resolve_server": "1.1.1.1",
"dns_resolve_type": "A"
}'
${TOKEN} can be obtained with:
TOKEN=$(curl -X 'POST' 'http://10.0.0.17:3002/login/access-token' -H 'accept: application/json' -H 'Content-Type: application/x-www-form-urlencoded' -d 'grant_type=&username=admin&password=MYPASSWORDFROMDOCKER' | jq -r ".access_token")
All those are bash commands on same server where docker container is runing
Any help? Thanks
My uptime kuma runs in a pterodactyl egg. i would like to run this API in pterodactyl too. Is that possible?
It would be very helpful if the access token expiry could be configured via a env setting. At the moment it expires every 8 days which makes it even more complicated to use in automated systems without overloading actions with additional requests to get a token, or by implementing scheduled renews of the auth token.
I am trying to use the Web API tool to access Uptime Kuma for automation of website and host checks.
During a first sync, the scripts ran into dozens of issues because the API failed to respond. I run into timeouts which are currently set to 60 seconds. From about 100-120 sites added via the API, 50 failed. ๐
The load is not really heavy, 1-2 requests per second. Already tried to find out what's causing the timeouts, but can't figure it out.
Here's a log example.
packet queue is empty, aborting
packet queue is empty, aborting
packet queue is empty, aborting
packet queue is empty, aborting
CRITICAL:
INFO: 192.168.192.1:53938 - "POST /monitors/ HTTP/1.1" 500 Internal Server Error
INFO: 192.168.192.1:53948 - "POST /monitors/ HTTP/1.1" 200 OK
packet queue is empty, aborting
INFO: 192.168.192.1:45754 - "POST /monitors/ HTTP/1.1" 200 OK
INFO: 192.168.192.1:60040 - "GET /monitors/ HTTP/1.1" 200 OK
packet queue is empty, aborting
INFO: 192.168.192.1:43932 - "POST /monitors/ HTTP/1.1" 200 OK
Example error from the scripts
cURL error 28: Operation timed out after 60000 milliseconds with 0 bytes received (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://my-private-domain/monitors/
Any idea what the issue could be? Are there any logs about those internal server errors as seen above?
By default medaziz11/uptimekuma_restapi appears to run under uid 100.
This results in permissions errors on startup unless uid 100 has access to the /db volume.
sqlite3.OperationalError: unable to open database file
Giving the volume full 777 permissions allows for the sqlite db to be created, but under ownership of uid 100, which on my system is the default 'systemd-timesync' user:
dockeradmin@dockerhost:/dockershared/uptimekuma$ grep "x:100:" /etc/passwd
systemd-timesync:x:100:102:systemd Time Synchronization,,,:/run/systemd:/usr/sbin/nologin
dockeradmin@dockerhost:/dockershared/uptimekuma$ ll apidb
total 24
drwxrwxrwx 2 dockeradmin docker 4096 Nov 30 22:07 ./
drwxr-xr-x 4 dockeradmin docker 4096 Nov 30 22:08 ../
-rw-r--r-- 1 systemd-timesync systemd-journal 16384 Nov 30 22:07 db.sqlite3
This is not ideal so I attempted to force use of a different user by adding the following line to my docker-compose file:
user: 1000:1000
Which resulted in the following errors accessing /tmp when attempting to start up the container:
[2023-11-30 22:09:16 +0000] [1] [INFO] Unhandled exception in main loop
Traceback (most recent call last):
File "/app/venv/lib/python3.9/site-packages/gunicorn/arbiter.py", line 202, in run
self.manage_workers()
File "/app/venv/lib/python3.9/site-packages/gunicorn/arbiter.py", line 551, in manage_workers
self.spawn_workers()
File "/app/venv/lib/python3.9/site-packages/gunicorn/arbiter.py", line 622, in spawn_workers
self.spawn_worker()
File "/app/venv/lib/python3.9/site-packages/gunicorn/arbiter.py", line 569, in spawn_worker
worker = self.worker_class(self.worker_age, self.pid, self.LISTENERS,
File "/app/venv/lib/python3.9/site-packages/uvicorn/workers.py", line 23, in __init__
super(UvicornWorker, self).__init__(*args, **kwargs)
File "/app/venv/lib/python3.9/site-packages/gunicorn/workers/base.py", line 64, in __init__
self.tmp = WorkerTmp(cfg)
File "/app/venv/lib/python3.9/site-packages/gunicorn/workers/workertmp.py", line 29, in __init__
util.chown(name, cfg.uid, cfg.gid)
File "/app/venv/lib/python3.9/site-packages/gunicorn/util.py", line 153, in chown
os.chown(path, uid, gid)
PermissionError: [Errno 1] Operation not permitted: '/tmp/wgunicorn-nyytxa4w'
What is the correct method to change what user the container is running as if I want to avoid uid 100?
Hello,
To begin thank for your work, with your rest api I can use kuma !!!!
I try to make it work but it's seem there is an issue when we use reverse proxy (on synology for me), when I try to get access-token it's redirect me from port 443 to port 80. On app log I got :
I do something wrong or it's not supported ?
Thank in advance,
H! I need some help with the create monitor call, probably my json array is wrong:
{
"type": "http",
"name": "mysite",
"interval": 60,
"retryInterval": 60,
"resendInterval": 0,
"maxretries": 0,
"upsideDown": false,
"notificationIDList": [],
"url": "https://mysite.example.com",
"expiryNotification": false,
"ignoreTls": false,
"maxredirects": 10,
"accepted_statuscodes": [
"200-299"
],
"proxyId": 0,
"method": "GET",
"body": "",
"headers": "",
"authMethod": "",
"basic_auth_user": "",
"basic_auth_pass": "",
"authDomain": "",
"authWorkstation": "",
"keyword": "",
"hostname": "",
"port": 443,
"dns_resolve_server": "1.1.1.1",
"dns_resolve_type": "A",
"mqttUsername": "",
"mqttPassword": "",
"mqttTopic": "",
"mqttSuccessMessage": "",
"databaseConnectionString": "",
"databaseQuery": "",
"docker_container": "",
"docker_host": 0,
"radiusUsername": "",
"radiusPassword": "",
"radiusSecret": "",
"radiusCalledStationId": "",
"radiusCallingStationId": ""
}
This is giving me the following error:
{"detail":"insert into `monitor` (`accepted_statuscodes_json`, `auth_method`, `body`, `database_connection_string`, `dns_resolve_server`, `dns_resolve_type`, `expiry_notification`, `headers`, `hostname`, `ignore_tls`, `interval`, `maxredirects`, `maxretries`, `method`, `mqtt_password`, `mqtt_success_message`, `mqtt_topic`, `mqtt_username`, `name`, `port`, `proxy_id`, `resend_interval`, `retry_interval`, `type`, `upside_down`, `url`, `user_id`) values ('[\"200-299\"]', '', '', '', '1.1.1.1', 'A', false, '', '', false, 60, 10, 0, 'GET', '', '', '', '', 'index.entornos.net', 443, 0, 0, 60, 'http', false, 'https://index.entornos.net', 1) - SQLITE_CONSTRAINT: FOREIGN KEY constraint failed"}
@MedAziz11 thank you in advance for your help and for this great project! Is just what we needed for uptime kuma ! ๐
It looks like the Swagger UI does not allow connecting to the API using a bearer token.
When I click the "Authorize" button, I am only offered to fill credentials for "OAuth2PasswordBearer (OAuth2, password)" security scheme.
If enabled, the Bearer authentication HTTP authentication scheme one could use, on the Swagger UI, the token the README explain how to get.
I succesfully installed the docker-compose containers and I have both ports working with uptime kuma and the api.
However when I try to login via the Swagger page or via Postman I'm getting the message:
{ "detail": { "message": "Incorrect Kuma credentials" } }
And the login seems to be ok, because if I try to use another password or username I'm getting:
{ "detail": { "message": "Incorrect username or password" } }
The curl example doesn't seem to be working for me also. I'm getting an Internal Server Error response.
I'm not sure if it's a bug or something related with the permissions problem #33 that I already managed to solve (apparently) with the instructions provided there.
Hi,
sorry not sure where to ask, I vaguely understand what this does, but is there any endpoint to trigger a monitor's maintenance mode in uptime-kuma on and off via curl? Apologies if it's apparent from the description and/or the picture I'm a dum dum.
When I change the Admin_Pass on docker compose, it does not take effect even when performing a Docker Down and Up.
I ended up deleting the DB files under /var/lib/docker/volumes/kuma_api/_data and perform a docker compose up in order for the new Admin_Pass to take in effect.
Is there a better way to do this?
Hi, thanks for your project.
I made a script which is creating many monitors at once, but max that I get is 6 successful, the rest of them which fails get reply with json: {"detail":"'version'"}
, logs are saying: [7] [CRITICAL] 'version'
. I tried to increase pauses to 30 sec between requests, but no luck.
Here is my script:
#!/bin/bash
UPTIME_USER="admin"
UPTIME_API_PASSWORD="admin"
UPTIME_URL="http://localhost:8000"
TOKEN_FILE=./token
# Putting the list of desired monitors
MONITOR_TYPE="ping"
project_id_array=(
"server01.domain.org"
"server02.domain.org"
"server03.domain.org"
"server04.domain.org"
"server05.domain.org"
"server06.domain.org"
"server07.domain.org"
"server08.domain.org"
)
# Check the file with token
if [ -f "${TOKEN_FILE}" ]; then
# If exists, read from it
TOKEN=$(cat "${TOKEN_FILE}")
else
# If there is no file, get a new token..
TOKEN=$(curl -s -L -X POST -H "Content-Type: application/x-www-form-urlencoded" \
--data "username=${UPTIME_USER}&password=${UPTIME_API_PASSWORD}" \
"${UPTIME_URL}/login/access-token" | jq -r '.access_token')
# ..and save it to token file
echo "${TOKEN}" > "${TOKEN_FILE}"
fi
# Cycle for adding monitors
for project_id in "${project_id_array[@]}"; do
echo "Create monitor in Uptime Kuma for ${project_id}"
RESULT=$(curl -s -X POST -H "Content-Type: application/json" \
-H "Authorization: Bearer ${TOKEN}" \
-d '{"name": "'${project_id}'",
"pathName": "'${project_id}'",
"hostname": "'${project_id}'",
"maxretries": 3,
"active": true,
"forceInactive": false,
"type": "'${MONITOR_TYPE}'",
"timeout": 0,
"interval": 60,
"retryInterval": 60,
"resendInterval": 0,
"packetSize": 56
}' \
"${UPTIME_URL}/monitors")
# Check if token is valid, if no - delete the token file and ask user to run the script again
if [[ $RESULT == *"invalid credentials"* ]]; then
echo "Invalid Credentials"
rm -f "${TOKEN_FILE}"
echo "Please run the script again"
break
fi
# If token is OK, show monitor ID
monitor_id=$(echo "$RESULT" | jq -r '.monitorID')
echo "Monitor ID: ${monitor_id}"
# Making a pause between next requests
sleep 3
done
Deployment:
version: "3.9"
services:
kuma:
container_name: uptime-kuma
image: louislam/uptime-kuma:latest
ports:
- "3001:3001"
restart: always
volumes:
- uptime-kuma:/app/data
api:
container_name: backend
image: medaziz11/uptimekuma_restapi
volumes:
- api:/db
restart: always
environment:
- KUMA_SERVER=http://uptime-kuma:3001
- KUMA_USERNAME=admin
- KUMA_PASSWORD=Cdewsxzaq2002
- ADMIN_PASSWORD=admin
- ACCESS_TOKEN_EXPIRATION=60
depends_on:
- kuma
ports:
- "8000:8000"
volumes:
uptime-kuma:
api:
I encountered an error while attempting to create a monitor of type json-query
through the [POST] /monitors API endpoint.
I sent the following JSON payload in the request body:
{
"name": "example-monitor",
"url": "mydomain.com/v1/health",
"method": "GET",
"maxretries": 1,
"type": "json-query",
"timeout": 10,
"interval": 60,
"retryInterval": 20,
"resendInterval": 0,
"maxredirects": 10,
"accepted_statuscodes": ["200-299"],
"dns_resolve_type": "A",
"dns_resolve_server": "1.1.1.1",
"httpBodyEncoding": "json",
"jsonPath": "msg",
"expectedValue": "ok"
}
{
"detail": [
{
"loc": ["body", "type"],
"msg": "value is not a valid enumeration member; permitted: 'http', 'port', 'ping', 'keyword', 'grpc-keyword', 'dns', 'docker', 'push', 'steam', 'gamedig', 'mqtt', 'sqlserver', 'postgres', 'mysql', 'mongodb', 'radius', 'redis'",
"type": "type_error.enum",
"ctx": {
"enum_values": [
"http",
"port",
"ping",
"keyword",
"grpc-keyword",
"dns",
"docker",
"push",
"steam",
"gamedig",
"mqtt",
"sqlserver",
"postgres",
"mysql",
"mongodb",
"radius",
"redis"
]
}
}
]
}
Is json-query
not a supported monitor type, or could this be an issue with the API or my request format? Any guidance or solutions to enable creating a monitor of type json-query
would be highly appreciated.
Thank you for your assistance!
Hi,
When I attempt to retrieve my slug, I encounter an unknown error in the documentation:
{
"detail": "Unexpected Error: 'version'"
}
Here is the log I receive:
tools-uptime-kuma_api.1.uwhwpvl7k6vh@cdalr-prd-docker-06 | [2024-01-26 09:03:31 +0000] [178514] [CRITICAL] 'version'
Please advise on how to address this issue.
I could very well be just over looking this, but where can I pull current monitor status from? ie is a monitor "up or down"?
Hi,
im not able to authorize.
Commands and terminal output. I've added -s to supress the progress. Without -s same output.
[root@mysrv systools]$ TOKEN=$(curl -s -X POST -L -H 'Content-Type: application/x-www-form-urlencoded' --data 'username=admin&password=admin' http://127.0.0.1:8000/login/access-token/ | jq -r ".access_token")
[root@mysrv systools]$ echo $TOKEN
null
[root@mysrv systools]$ curl -L -H 'Accept: application/json' -H "Authorization: Bearer ${TOKEN}" http://127.0.0.1:8000/monitors/
Internal Server Error
docker logs
[2023-06-30 15:48:37 +0200] [1] [INFO] Starting gunicorn 20.1.0
[2023-06-30 15:48:37 +0200] [1] [INFO] Listening at: http://0.0.0.0:8000 (1)
[2023-06-30 15:48:37 +0200] [1] [INFO] Using worker: uvicorn.workers.UvicornWorker
[2023-06-30 15:48:37 +0200] [7] [INFO] Booting worker with pid: 7
[2023-06-30 15:48:38 +0200] [7] [INFO] Started server process [7]
[2023-06-30 15:48:38 +0200] [7] [INFO] Waiting for application startup.
[2023-06-30 15:48:38 +0200] [7] [INFO] KumaAPI started...
[2023-06-30 15:48:38 +0200] [7] [INFO] Application startup complete.
[2023-06-30 15:49:01 +0200] [7] [CRITICAL] hello from http://192.168.242.49:3001
[2023-06-30 15:49:01 +0200] [7] [INFO] Logged in to UptimeKuma
[2023-06-30 15:49:01 +0200] [7] [CRITICAL] 'token'
[2023-06-30 15:49:16 +0200] [7] [ERROR] Exception in ASGI application
Traceback (most recent call last):
File "/app/venv/lib/python3.9/site-packages/jwt/api_jws.py", line 180, in _load
signing_input, crypto_segment = jwt.rsplit(b'.', 1)
ValueError: not enough values to unpack (expected 2, got 1)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/app/venv/lib/python3.9/site-packages/uvicorn/protocols/http/httptools_impl.py", line 436, in run_asgi
result = await app( # type: ignore[func-returns-value]
File "/app/venv/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
return await self.app(scope, receive, send)
File "/app/venv/lib/python3.9/site-packages/fastapi/applications.py", line 270, in __call__
await super().__call__(scope, receive, send)
File "/app/venv/lib/python3.9/site-packages/starlette/applications.py", line 124, in __call__
await self.middleware_stack(scope, receive, send)
File "/app/venv/lib/python3.9/site-packages/starlette/middleware/errors.py", line 184, in __call__
raise exc
File "/app/venv/lib/python3.9/site-packages/starlette/middleware/errors.py", line 162, in __call__
await self.app(scope, receive, _send)
File "/app/venv/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 75, in __call__
raise exc
File "/app/venv/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 64, in __call__
await self.app(scope, receive, sender)
File "/app/venv/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
raise e
File "/app/venv/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
await self.app(scope, receive, send)
File "/app/venv/lib/python3.9/site-packages/starlette/routing.py", line 680, in __call__
await route.handle(scope, receive, send)
File "/app/venv/lib/python3.9/site-packages/starlette/routing.py", line 275, in handle
await self.app(scope, receive, send)
File "/app/venv/lib/python3.9/site-packages/starlette/routing.py", line 65, in app
response = await func(request)
File "/app/venv/lib/python3.9/site-packages/fastapi/routing.py", line 221, in app
solved_result = await solve_dependencies(
File "/app/venv/lib/python3.9/site-packages/fastapi/dependencies/utils.py", line 533, in solve_dependencies
solved = await call(**sub_values)
File "/app/utils/deps.py", line 20, in get_current_user
payload = jwt.decode(
File "/app/venv/lib/python3.9/site-packages/jwt/api_jwt.py", line 84, in decode
payload, _, _, _ = self._load(jwt)
File "/app/venv/lib/python3.9/site-packages/jwt/api_jws.py", line 183, in _load
raise DecodeError('Not enough segments')
jwt.exceptions.DecodeError: Not enough segments
My docker-compose.yml
uptime-kuma:
image: louislam/uptime-kuma:alpine
container_name: uptime-kuma
volumes:
- /share/CACHEDEV1_DATA/Container/uptime-kuma:/app/data
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
environment:
- TZ=Europe/Berlin
restart: always
mac_address: 24:5E:BE:00:00:49
networks:
myBridgeNet:
ipv4_address: 192.168.242.49
uptime-kuma-api:
container_name: uptime-kuma-api
image: medaziz11/uptimekuma_restapi:latest
volumes:
- /share/CACHEDEV1_DATA/Container/uptime-kuma/api:/db:rw
- /etc/localtime:/etc/localtime:ro
restart: always
environment:
- TZ=Europe/Berlin
- PUID=1000
- PGID=1000
- KUMA_SERVER=http://192.168.242.49:3001
- KUMA_USERNAME=admin
- KUMA_PASSWORD=UptimeKuma_PASSWORD
- ADMIN_PASSWORD=admin
- SECRET_KEY=UptimeKuma_API_TOKEN
depends_on:
- uptime-kuma
ports:
- 8000:8000
Hi,
I try the curl example script:
===
TOKEN=$(curl -X -L 'POST' -H 'Content-Type: application/x-www-form-urlencoded' --data 'username=admin&password=admin' http://127.0.0.1:8000/login/access-token/ | jq -r ".access_token")
curl -L -H 'Accept: application/json' -H "Authorization: Bearer ${TOKEN}" http://127.0.0.1:8000/monitors/
===
I replace only the port and password for Kuma API. Any suggestion?
Could the application be configured to run under a specific URL path.
Say I want to make it available at URL https://monitoring.example.com/uptime-api/
I can, from my web reverse proxy, strip the /uptime-api
part prior to passing it to the Docker container running the medaziz11/uptimekuma_restapi
image. But in the obtained response contains URL that refers to the root of the server.
Thus, when I try to access https://monitoring.example.com/uptime-api/
, I get a location: /docs
HTTP 307 response.
If I try to access https://monitoring.example.com/uptime-api/docs, I get the correct HTML document but it asks for /openapi.json
, not https://monitoring.example.com/uptime-api/openapi.json
.
If there was some configuration/option to declare the path the application is expected to execute from it would be useful.
(I guess can submit a PR for this)
Not sure if i'm missing a step here but when spinning up the docker image, using the example provided, the uptime-kuma
starts up fine, but api-1
errors with:
exec /app/entrypoint.sh: no such file or directory
If i inspect the files though I can see that the folder app
exists and entrypoint.sh
file also exists. I'm using docker desktop for Windows (with WSL2)
Any advice appreciated
Thanks
Take this example yaml.
Simple test in docker swarm via Traefik
version: '3.9'
services:
uptime-kuma:
image: louislam/uptime-kuma:1.21.2-alpine
deploy:
replicas: 1
restart_policy:
condition: on-failure
update_config:
order: start-first
parallelism: 1
delay: 10s
failure_action: rollback
monitor: 60s
max_failure_ratio: 0.3
image: louislam/uptime-kuma:1.21.2-alpine
deploy:
replicas: 1
restart_policy:
condition: on-failure
update_config:
order: start-first
parallelism: 1
delay: 10s
failure_action: rollback
monitor: 60s
max_failure_ratio: 0.3
placement:
constraints: [node.labels.web-node == true]
labels:
# Enable Traefik for this service, to make it available in the public network
- traefik.enable=true
# Use the traefik-public network (declared below)
- traefik.docker.network=traefik-public
- traefik.constraint-label=traefik-public
# https-redirect middleware to redirect HTTP to HTTPS
# It can be re-used by other stacks in other Docker Compose files
- traefik.http.middlewares.https-redirect.redirectscheme.scheme=https
- traefik.http.middlewares.https-redirect.redirectscheme.permanent=true
# traefik-http set up only to use the middleware to redirect to https
- traefik.http.routers.kuma-http.rule=Host(`uptime-dev.example.com`)
- traefik.http.routers.kuma-http.entrypoints=http
# Middlewares #
- traefik.http.routers.kuma-http.middlewares=https-redirect,example-ipwhitelist@docker
- traefik.http.routers.kuma-https.middlewares=example-ipwhitelist@docker
# traefik-https the actual router using HTTPS
- traefik.http.routers.kuma-https.rule=Host(`uptime-dev.example.com`)
- traefik.http.routers.kuma-https.entrypoints=https
- traefik.http.routers.kuma-https.tls=true
# Use the special Traefik service api@internal with the web UI/Dashboard
# Use the "le" (Let's Encrypt) resolver created below
- traefik.http.routers.kuma-https.tls.certresolver=le
# Enable HTTP Basic auth, using the middleware created above
# Define the port inside of the Docker service to use
- traefik.http.services.kuma-service.loadbalancer.server.port=3001
healthcheck:
test: "wget --spider --quiet http://localhost:3001 || exit 1"
interval: 30s
timeout: 10s
retries: 5
start_period: 120s
networks:
- traefik-public
- kuma-internal
volumes:
- "/nfs_data/status_example_com/app/data:/app/data" #owned by user 1000 on NFS
uptime-kuma-api:
image: registry.example.com/devops/uptime-kuma-web-api:0.4
restart: always
volumes:
- /nfs_data/status_example_com/api/db:/db/ # Owned by app user in container (POSIX)
environment:
- KUMA_SERVER=${KUMA_SERVER:-http://uptime-kuma:3001}
- KUMA_USERNAME=${KUMA_USERNAME:-admin}
- KUMA_PASSWORD=${KUMA_PASSWORD}
- ADMIN_PASSWORD=${ADMIN_PASSWORD}
- ACCESS_TOKEN_EXPIRATION=${ACCESS_TOKEN_EXPIRATION:-5}
deploy:
replicas: 1
restart_policy:
condition: on-failure
update_config:
order: start-first
parallelism: 1
delay: 10s
failure_action: rollback
monitor: 60s
max_failure_ratio: 0.3
placement:
constraints: [node.labels.web-node == true]
labels:
# Enable Traefik for this service, to make it available in the public network
- traefik.enable=true
# Use the traefik-public network (declared below)
- traefik.docker.network=traefik-public
- traefik.constraint-label=traefik-public
# https-redirect middleware to redirect HTTP to HTTPS
# It can be re-used by other stacks in other Docker Compose files
- traefik.http.middlewares.https-redirect.redirectscheme.scheme=https
- traefik.http.middlewares.https-redirect.redirectscheme.permanent=true
# traefik-http set up only to use the middleware to redirect to https
- traefik.http.routers.kuma-api-http.rule=Host(`uptime-dev-api.example.com`)
- traefik.http.routers.kuma-api-http.entrypoints=http
# Middlewares #
- traefik.http.routers.kuma-api-http.middlewares=https-redirect,example-ipwhitelist@docker
- traefik.http.routers.kuma-api-https.middlewares=example-ipwhitelist@docker
# traefik-https the actual router using HTTPS
- traefik.http.routers.kuma-api-https.rule=Host(`uptime-dev-api.example.com`)
- traefik.http.routers.kuma-api-https.entrypoints=https
- traefik.http.routers.kuma-api-https.tls=true
# Use the special Traefik service api@internal with the web UI/Dashboard
# Use the "le" (Let's Encrypt) resolver created below
- traefik.http.routers.kuma-api-https.tls.certresolver=le
# Enable HTTP Basic auth, using the middleware created above
# Define the port inside of the Docker service to use
- traefik.http.services.kuma-api-service.loadbalancer.server.port=8000
networks:
- traefik-public
- kuma-internal
When hitting two replicas via non-sticky load-balancer, the token seems to be invalid.
I think there is some dependency on the individual container's validation of the token, that is currently not suited for a stateless environment.
Will investigate.
Parameter for #localtime and #timezone would be fine to have the same date/time as the Uptime-Kume container.
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
# Add support tools
RUN apk update && apk add --no-cache tzdata
Hello
running latest Uptime-Kuma and Uptime-Kuma-Web-API Docker image under RPi4 64 bit.
Command
curl -X 'GET' \
'http://hadersdorf.myDomain.com:3002/statuspages' \
-H 'accept: application/json' \
-H 'Authorization: Bearer <...>'
Result
Internal Server Error
Uptime-Kuma-Web-API Logs
[2023-11-18 10:10:12 +0100] [7] [ERROR] Exception in ASGI application
Traceback (most recent call last):
File "/app/venv/lib/python3.9/site-packages/uvicorn/protocols/http/httptools_impl.py", line 436, in run_asgi
result = await app( # type: ignore[func-returns-value]
File "/app/venv/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
return await self.app(scope, receive, send)
File "/app/venv/lib/python3.9/site-packages/fastapi/applications.py", line 270, in __call__
await super().__call__(scope, receive, send)
File "/app/venv/lib/python3.9/site-packages/starlette/applications.py", line 124, in __call__
await self.middleware_stack(scope, receive, send)
File "/app/venv/lib/python3.9/site-packages/starlette/middleware/errors.py", line 184, in __call__
raise exc
File "/app/venv/lib/python3.9/site-packages/starlette/middleware/errors.py", line 162, in __call__
await self.app(scope, receive, _send)
File "/app/venv/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 75, in __call__
raise exc
File "/app/venv/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 64, in __call__
await self.app(scope, receive, sender)
File "/app/venv/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
raise e
File "/app/venv/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
await self.app(scope, receive, send)
File "/app/venv/lib/python3.9/site-packages/starlette/routing.py", line 680, in __call__
await route.handle(scope, receive, send)
File "/app/venv/lib/python3.9/site-packages/starlette/routing.py", line 275, in handle
await self.app(scope, receive, send)
File "/app/venv/lib/python3.9/site-packages/starlette/routing.py", line 65, in app
response = await func(request)
File "/app/venv/lib/python3.9/site-packages/fastapi/routing.py", line 249, in app
content = await serialize_response(
File "/app/venv/lib/python3.9/site-packages/fastapi/routing.py", line 138, in serialize_response
raise ValidationError(errors, field.type_)
pydantic.error_wrappers.ValidationError: 1 validation error for StatusPageList
response -> statuspages -> 1 -> domainNameList -> 0
invalid or missing URL scheme (type=value_error.url.scheme)
Thanks!
Can support hosting on replit?
Error from log container:
return await func(self, query, *args)
File "/app/venv/lib/python3.9/site-packages/tortoise/backends/sqlite/client.py", line 153, in execute_script
async with self.acquire_connection() as connection:
File "/app/venv/lib/python3.9/site-packages/tortoise/backends/base/client.py", line 220, in aenter
await self.ensure_connection()
File "/app/venv/lib/python3.9/site-packages/tortoise/backends/base/client.py", line 216, in ensure_connection
await self.client.create_connection(with_db=True)
File "/app/venv/lib/python3.9/site-packages/tortoise/backends/sqlite/client.py", line 69, in create_connection
await self._connection._connect()
File "/app/venv/lib/python3.9/site-packages/aiosqlite/core.py", line 137, in _connect
self.connection = await future
File "/app/venv/lib/python3.9/site-packages/aiosqlite/core.py", line 102, in run
result = function()
File "/app/venv/lib/python3.9/site-packages/aiosqlite/core.py", line 397, in connector
return sqlite3.connect(loc, **kwargs)
sqlite3.OperationalError: unable to open database file
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/app/venv/lib/python3.9/site-packages/starlette/routing.py", line 645, in lifespan
async with self.lifespan_context(app):
File "/app/venv/lib/python3.9/site-packages/starlette/routing.py", line 540, in aenter
await self.router.startup()
File "/app/venv/lib/python3.9/site-packages/starlette/routing.py", line 622, in startup
await handler()
File "/app/main.py", line 41, in startup_event
await initialize_app(app)
File "/app/app_setup.py", line 10, in initialize_app
await setup_database()
File "/app/app_setup.py", line 29, in setup_database
await Tortoise.generate_schemas()
File "/app/venv/lib/python3.9/site-packages/tortoise/init.py", line 636, in generate_schemas
await generate_schema_for_client(connection, safe)
File "/app/venv/lib/python3.9/site-packages/tortoise/utils.py", line 31, in generate_schema_for_client
await generator.generate_from_string(schema)
File "/app/venv/lib/python3.9/site-packages/tortoise/backends/base/schema_generator.py", line 448, in generate_from_string
await self.client.execute_script(creation_string)
File "/app/venv/lib/python3.9/site-packages/tortoise/backends/sqlite/client.py", line 36, in translate_exceptions
raise OperationalError(exc)
tortoise.exceptions.OperationalError: unable to open database file
[2023-05-17 18:21:24 +0000] [7] [ERROR] Application startup failed. Exiting.
[2023-05-17 18:21:24 +0000] [7] [INFO] Worker exiting (pid: 7)
[2023-05-17 18:21:24 +0000] [1] [INFO] Shutting down: Master
[2023-05-17 18:21:24 +0000] [1] [INFO] Reason: Worker failed to boot.
[2023-05-17 18:21:31 +0000] [1] [INFO] Starting gunicorn 20.1.0
[2023-05-17 18:21:31 +0000] [1] [INFO] Listening at: http://0.0.0.0:8000 (1)
[2023-05-17 18:21:31 +0000] [1] [INFO] Using worker: uvicorn.workers.UvicornWorker
[2023-05-17 18:21:31 +0000] [7] [INFO] Booting worker with pid: 7
[2023-05-17 18:21:31 +0000] [7] [INFO] Started server process [7]
[2023-05-17 18:21:31 +0000] [7] [INFO] Waiting for application startup.
[2023-05-17 18:21:32 +0000] [7] [ERROR] Traceback (most recent call last):
File "/app/venv/lib/python3.9/site-packages/tortoise/backends/sqlite/client.py", line 34, in translate_exceptions
return await func(self, query, *args)
File "/app/venv/lib/python3.9/site-packages/tortoise/backends/sqlite/client.py", line 153, in execute_script
async with self.acquire_connection() as connection:
File "/app/venv/lib/python3.9/site-packages/tortoise/backends/base/client.py", line 220, in aenter
await self.ensure_connection()
File "/app/venv/lib/python3.9/site-packages/tortoise/backends/base/client.py", line 216, in ensure_connection
await self.client.create_connection(with_db=True)
File "/app/venv/lib/python3.9/site-packages/tortoise/backends/sqlite/client.py", line 69, in create_connection
await self._connection._connect()
File "/app/venv/lib/python3.9/site-packages/aiosqlite/core.py", line 137, in _connect
self._connection = await future
File "/app/venv/lib/python3.9/site-packages/aiosqlite/core.py", line 102, in run
result = function()
File "/app/venv/lib/python3.9/site-packages/aiosqlite/core.py", line 397, in connector
return sqlite3.connect(loc, **kwargs)
sqlite3.OperationalError: unable to open database file
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/app/venv/lib/python3.9/site-packages/starlette/routing.py", line 645, in lifespan
async with self.lifespan_context(app):
File "/app/venv/lib/python3.9/site-packages/starlette/routing.py", line 540, in aenter
await self.router.startup()
File "/app/venv/lib/python3.9/site-packages/starlette/routing.py", line 622, in startup
await handler()
File "/app/main.py", line 41, in startup_event
await initialize_app(app)
File "/app/app_setup.py", line 10, in initialize_app
await setup_database()
File "/app/app_setup.py", line 29, in setup_database
await Tortoise.generate_schemas()
File "/app/venv/lib/python3.9/site-packages/tortoise/init.py", line 636, in generate_schemas
await generate_schema_for_client(connection, safe)
File "/app/venv/lib/python3.9/site-packages/tortoise/utils.py", line 31, in generate_schema_for_client
await generator.generate_from_string(schema)
File "/app/venv/lib/python3.9/site-packages/tortoise/backends/base/schema_generator.py", line 448, in generate_from_string
await self.client.execute_script(creation_string)
File "/app/venv/lib/python3.9/site-packages/tortoise/backends/sqlite/client.py", line 36, in translate_exceptions
raise OperationalError(exc)
tortoise.exceptions.OperationalError: unable to open database file
[2023-05-17 18:21:32 +0000] [7] [ERROR] Application startup failed. Exiting.
[2023-05-17 18:21:32 +0000] [7] [INFO] Worker exiting (pid: 7)
[2023-05-17 18:21:32 +0000] [1] [INFO] Shutting down: Master
[2023-05-17 18:21:32 +0000] [1] [INFO] Reason: Worker failed to boot.
My Docker Compose is:
version: "3.9"
services:
api:
build: .
#image: medaziz11/uptimekuma_restapi
volumes:
- ./db:/db:rwx
container_name: kuma_restapi
restart: always
networks:
- network_public
environment:
- KUMA_SERVER=${KUMA_SERVER:-http://kuma:3001}
- KUMA_USERNAME=${KUMA_USERNAME:-USER}
- KUMA_PASSWORD=${KUMA_PASSWORD:-PASSWORD}
- ADMIN_PASSWORD=${ADMIN_PASSWORD:-PASSWORD}
# - ACCESS_TOKEN_EXPIRATION=${ACCESS_TOKEN_EXPIRATION:-1}
- SECRET_KEY=${SECRET_KEY:-uk2_FYWegoBdM9aAUJAJ5c6AVz3rtCwT2yglQGMxWyT1} #random 32bit string that's url safe.
Hi all,
Would someone please have spare moment and help with POST method for creating new Monitor.
I am trying to figure out what data is requierd to be sent in request.
Thanks!
Hi,
when I try to create a monitor with [POST] /monitors and passing this in the request body:
{ "type": "http", "name": "website", "url":"https://example.com" }
I got this in response
status: 500
body:
{ "detail": "'version'" }
do you have a solution for me?
Thanks for your help :)
Currently, this API cannot communicate with Uptime Kuma if the account has two factor authentication enabled.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.