Grafana에서 Alert을 보내는 방법은 여러가지가 있다. 그런데 대부분 메세지 기반의 서비스 들이다. 병원에서 쓰려면 소리가 나야 하는 법. 그래서 찾아봤더니 Node-RED를 이용해서 구현할 수 있는 것 같았다.

Sound alerts on Grafana 9
@rogerfor7 Well this did not take long at all. Here’s what I did: Set up Webhook contact point (leave all other settings blank…just remember to select POST in the HTTP method) Test the alert by clicking on the blue button Over on 192.168.10.235:1880, where we have Node-RED running w…
그래서 Node-RED를 설치해 보았다. 오늘의 목표는 소리가 나게 하는 것이다. 다음과 같이 Node-RED를 도커로 설치한다.
sudo docker run -it \
-p 1880:1880 \
--name mynodered \
nodered/node-red
방화벽에서도 1880을 포워딩 시켜준다.
add action=dst-nat chain=dstnat comment=node_red dst-port=1880 protocol=tcp src-address-list=trusted_source to-addresses=10.10.10.184 to-ports=1880
웹브라우저에서 소리가 나는 것을 구현하기 위해서 필요한 Node-RED의 라이브러리는 다음과 같다. 도커에서 실행시키기 위해서는 다음과 같이 한다.
$ sudo docker exec -it mynodered /bin/bash
이렇게 하면 bash 창이 나온다. 다음의 명령어를 이용하여 라이브러리를 설치한다. dashboard도 같이 설치해 준다.
npm install node-red-dashboard
npm install node-red-contrib-play-audio
다음과 같이 하면 된다. chime.mp3 와 관련된 부분을 지정할 때에는 ‘file in’을 선택하고, 경로는 가능하면 절대 경로로 한다. Output에는 Buffer라고 되어 있는 2개중 하나를 선택하면 된다.


그리고 Deploy 시킨다. curl 을 이용하여 확인해 보려면 다음과 같이 한다.
$ curl -v -X POST localhost:1880/hello