Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Implement endpoint or push notifications for source health checks #66

Closed
FoxxMD opened this issue Feb 3, 2023 · 5 comments
Closed
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@FoxxMD
Copy link
Owner

FoxxMD commented Feb 3, 2023

Based on #65

[ ] Implement a healthcheck endpoint to monitor status (running/idle) of sources/clients
[ ] Integrate discord webhook or something like pusher webhook to allow notifications when health changes for sources/clients

@FoxxMD FoxxMD added the enhancement New feature or request label Feb 3, 2023
@Karsten-Yan
Copy link

The webhook would probably also support REST notification services like gotify or notify.sh, correct? If so, that would be awesome, looking forward to that feature!

@FoxxMD FoxxMD added the help wanted Extra attention is needed label Feb 10, 2023
FoxxMD added a commit that referenced this issue Feb 24, 2023
* Implemented notifications for Gotify and Ntfy
* Notifications pushed on: polling started, polling retry, polling stopped on error, scrobble client scrobble failure
FoxxMD added a commit that referenced this issue Feb 24, 2023
* HTTP Status as primary indicator with messages in json response
* No parameters in request aggregates all client/source statuses. Otherwise can use 'type' or 'name' parameters to restrict client/sources to aggregate
@FoxxMD
Copy link
Owner Author

FoxxMD commented Feb 24, 2023

@iluvatyr @Karsten-Yan

I've implemented webhooks for Gotify/Ntfy as well as a health check endpoint. Preview in develop

Webhooks can be added to config.json using webhooks property (see schema for examples and structure)

{
  "sources": [...],
  "clients": [...],
  "webhooks": [
    {
      "type": "gotify",
      "url": "..."
    }
  ],
}

For now, webhooks notifications only push for:

  • polling started
  • polling retry
  • polling stopped on error
  • scrobble client scrobble failure

Health endpoint can be accessed at http://YourMsURL/health

  • returns 200 when everything is working or 500 if anything is not
  • the plain url (/health) aggregates status of all clients/sources -- so any failing client/source will make status return 500
  • use query params type or name to restrict client/sources aggregated IE /health?type=spotify or /health?name=MyMaloja
  • on 500 response returns a JSON payload with "messages" that describes the issue
    • for any clients/sources that require authentication /health will return 500 if they are not authenticated
    • for sources that poll (spotify, yt music, subsonic) /health will 500 if they are not polling

@FoxxMD
Copy link
Owner Author

FoxxMD commented Feb 27, 2023

Implemented in v0.4.1. Docs here

If there are any other events you think webhooks should notify on let me know.

@FoxxMD FoxxMD closed this as completed Feb 27, 2023
@iluvatyr
Copy link

iluvatyr commented Feb 28, 2023

This is one of the best things! Thanks for this. Now it can be monitored both using uptime-kuma /uptimerobot via /health endpoint and also via gotify. Awesome! I already tested it and it works flawlessly for me.

I only suggest adding something to send a testmessage to test if the message is coming correctly, either by pressing "Ping gotify/ntfy" in webui, via accessing a URL (/notifytest or else) or via terminal command from within the docker container.

Also it would be great to be able to choose, which notifications should be used. Someone may for example not want to be notified for "polling started", or some only want to be notified for "polling failed". Although you making it possible to set priorities is already making this not a big problem.

@FoxxMD
Copy link
Owner Author

FoxxMD commented Feb 28, 2023

adding something to send a testmessage

I'll think about it...you can already verify your notification servers are at least reachable by checking the logs at startup. MS attempts to contact the servers on known version/health endpoints and will log an error or success based on that.

2023-02-28T12:43:23-05:00 verbose: [Gotify - Config 0] Initialized. Found Server version 2.2.4
2023-02-28T12:43:23-05:00 info   : [Ntfy - Config 1  ] Initialized. Found Ntfy server
2023-02-28T12:45:29-05:00 error  : [Gotify - Config 0] Failed to contact server | Error: connect ECONNREFUSED 192.168.0.100:8076
2023-02-28T12:45:32-05:00 error  : [Ntfy - Config 1  ] Failed to contact Ntfy server | Error: connect EHOSTUNREACH 192.168.0.100:9991

Will also think on filtering notification types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants