louislam / uptime-kuma

A fancy self-hosted monitoring tool
https://uptime.kuma.pet
MIT License
56.46k stars 5.07k forks source link

Webhook notification to LunaSea #130

Closed cnelson-pdx closed 3 years ago

cnelson-pdx commented 3 years ago

I use LunaSea for a lot of device notifications https://docs.lunasea.app/lunasea/notifications/custom-notifications

you can see at their wiki that they support custom notifications in JSON format, but are specifically title and body in the payload.

I used Webhook.site to view the payload you're sending and would love to see the title be "UptimeKuma: MonitorFriendlyName" and the body would be the msg currently sent "msg": "[Posterr] [🔴 Down] Request failed with status code 502" but maybe without the Monitor friendly name in brackets as that'd be in the Title already.

If this is beyond capability i understand, just thought i'd try as i really like the products look and feel so far

Thanks, Christian

louislam commented 3 years ago

You can get the error msg and the monitor name here:

{
  "heartbeat": {
    "monitorID": 2,
    "status": 0,   👈🏻👈🏻👈🏻👈🏻  0 = DOWN   1 = UP
    "time": "2021-07-31 03:58:23",
    "msg": "getaddrinfo ENOTFOUND test",👈🏻👈🏻👈🏻👈🏻
    "important": true,
    "duration": 0
  },
  "monitor": {
    "id": 2,
    "name": "test",👈🏻👈🏻👈🏻👈🏻👈🏻
    "url": "https://test",
    "hostname": null,
    "port": null,
    "maxretries": 0,
    "weight": 2000,
    "active": 1,
    "type": "http",
    "interval": 60,
    "keyword": null,
    "notificationIDList": {
      "3": true
    }
  },
  "msg": "[test] [🔴 Down] getaddrinfo ENOTFOUND test"
}
NiNiyas commented 3 years ago

@cnelson-pdx is this what you had in mind? LunaSea

cnelson-pdx commented 3 years ago

@cnelson-pdx is this what you had in mind? LunaSea

Yes, that is exactly what I was looking for. Is this something you modified yourself? or found via google? I tried my hand at looking through monitor.js and notification.js in UptimeKuma, but I'm no javascript developer and didn't have much luck.

Is this something I can modify myself pretty easy to work?

Thank you!

NiNiyas commented 3 years ago

I'll open a PR just in a minute.

louislam commented 3 years ago

Tested it successfully. Will be supported in next release. Thanks.

sassanix commented 2 months ago

How can I set this up now on lunasea? I don't see any customized webhook options.

CommanderStorm commented 2 months ago

How can I set this up

image

sassanix commented 2 months ago

Figured it out, I had to click on any of the webhooks in the lunasea app and then I got my id that way.

There isn't one setup just for uptime-kuma.

Thank you for your help though.

CommanderStorm commented 2 months ago

If there is something we can improve, we try to put it into the UI.

I don't have enough context on said notification provider. Could you write 1-2 sentences for https://github.com/louislam/uptime-kuma/blob/master/src/components/notifications/LunaSea.vue where the parameter can be found and how to get said notification provider working?

sassanix commented 2 months ago

If there is something we can improve, we try to put it into the UI.

I don't have enough context on said notification provider. Could you write 1-2 sentences for https://github.com/louislam/uptime-kuma/blob/master/src/components/notifications/LunaSea.vue where the parameter can be found and how to get said notification provider working?

I can definitely help with that; I will see how to add instructions there.