How to send Grafana alerts to SignalK
I'd like to use SignalK as a central point of all the notifications. I set up some alerts in Grafana and would like that they are posted to SignalK.
Setting aside Grafana as a source and assuming I'm doing this from command line using
curl
: what should be the high level sequence of steps to post a notification representing an alert into SignalK?
Is it necessary to login or not?
What API should be used to post a notification?
Thanks!6 Replies
Webhooks are typically via HTTP GET. Signalk uses PUT and POST to accept a JSON payload. What is the use case why Grafana as the source? What is the source of the metrics that triggers the alarm?
The scenario is roughly the following:
1. I have several devices (router, raspberry pi, SailroHat, CerboGX) that report vitals like network accessibility, load, available storage, etc.
2. This values get stored into InfluxDB.
3. In Grafana, I have alerts set up for events like when network accessibility is lost, or when storage space on Cerbo runs on
The missing step is to get these alerts into SignalK so that they will eventually be presented as alerts.
My first question is what is the right way to create one new notification in SignalK. So which API should be used, does one need to authnticate first?
The use case is not straightforward given all of the available software. You will need to develop a plugin that will accept the webhook GET request to a new endpoint and translate that into a Signalk delta, build a proxy service and host it for translating GET into PUT, or eliminate Grafana and use something like Node-Red to poll the database and develop alerting logic in JavaScript.
Regarding your questions, you can use the Signalk websocket API to send deltas. I suggest that you read the documentation to understand how this works. If auth is configured for your Signalk server, then yes you need to setup a valid token and use it for your requests.
All of the instructions are here https://signalk.org/specification/1.5.0/doc/
You could create a webhook handler in Node-RED and raise & reset notifications there
Agree, but there are now 3 separate steps required:
1. Grafana -> webhook
2. Webhook -> node-red
3. Node-red -> SignalK
btw, I chose https://github.com/adnanh/webhook
The extra webhook is required bcs I was not able to make the login from Grafana into Signalk directly bcs the URL for login differs from URL for the request and there can only be one URL defined in grafana alert
if I understood your point correctly: you can use
signalk-generate-token
to create a token that you can put in token
http query parameter to authenticate, no step number 2 needed
if you use the SK Node-RED plugin i don't consider 3 a "step", naturally you need to pass the notification from the handler to SK server