AutoKuma icon indicating copy to clipboard operation
AutoKuma copied to clipboard

Using kuma-client to create a status page

Open zodac-personal opened this issue 1 year ago • 3 comments

I'm trying to create a script that will create a status page for me on start-up if it doesn't already exist, but I'm having trouble with the kuma-client. I tried taking the output of status-page get my-slug and using it as the input to status-page add <file>, but ran into this error:

{"error":"Server responded with an error: Cannot set properties of null (setting 'status_page_id')"}

However, when I check UptimeKuma, the status page was created, but with no monitored services. I'm not sure what the format of the input file should be, or whether I need to use a different structure?

This is my status page JSON file:

{
  "status_page_id": 99, # Also tried "id", and even removing this key completely
  "slug": "test",
  "title": "Test",
  "icon": "/icon.svg",
  "theme": "dark",
  "published": true,
  "showTags": false,
  "domainNameList": [],
  "customCSS": "body {\n  \n}\n",
  "showPoweredBy": true,
  "showCertificateExpiry": false,
  "publicGroupList": [
    {
      "id": 1,
      "name": "Services",
      "weight": 1,
      "monitorList": [
        {
          "id": 1,
          "name": "My Site",
          "type": "http"
        }
      ]
    }
  ]
}

zodac-personal avatar Jun 05 '24 01:06 zodac-personal

Hi, sorry for the long delay, the problem is your pass an id value for your entry in the publicGroupList, but if you create a new status-page that group (and therefore it's id) doesn't exists. And yes when you add a group you should not supply a status_page_id, though I think uptime-kuma will ignore this and assign a new id anyway.

BigBoot avatar Oct 29 '24 05:10 BigBoot

Hey, thanks for the reply. I actually tried it with no id value too, but it didn't work. I can't remember if it had the same error, but I think it did. I can retry and confirm if needed, but it definitely didn't succeed.

zodac-personal avatar Oct 29 '24 08:10 zodac-personal

Just to make sure, I'm talking about this id specifically:

{
  "status_page_id": 99, # Also tried "id", and even removing this key completely
  "slug": "test",
  "title": "Test",
  "icon": "/icon.svg",
  "theme": "dark",
  "published": true,
  "showTags": false,
  "domainNameList": [],
  "customCSS": "body {\n  \n}\n",
  "showPoweredBy": true,
  "showCertificateExpiry": false,
  "publicGroupList": [
    {
-     "id": 1,
      "name": "Services",
      "weight": 1,
      "monitorList": [
        {
          "id": 1,
          "name": "My Site",
          "type": "http"
        }
      ]
    }
  ]
}

Additionally the status_page_id should also be removed, but I don't think it breaks anything, the monitor's id is actually required and needs to stay.

BigBoot avatar Oct 29 '24 09:10 BigBoot