Blog

  • Grafana를 Reverse Proxy에서 사용하기

    grafana.ini 에서 다음 부분을 수정한다. root_url 에는 리버스 프록시로 제공될 주소를 적는다. 그리고 serve_from_sub_path 를 true로 변경한다. 서비스를 재시작하면 된다.

    # If you use reverse proxy and sub path specify full url (with sub path)
    ;root_url = %(protocol)s://%(domain)s:%(http_port)s/
    root_url = %(protocol)s://%(domain)s/grafana-vital/
    
    # Serve Grafana from subpath specified in `root_url` setting. By default it is set to `false` for compatibility reasons.
    ;serve_from_sub_path = false
    serve_from_sub_path = true

    리버스 프록시를 제공하는 nginx 에서 관련 설정을 추가한다.

    location /grafana-vital/ {
    	proxy_pass http://grafana.rcc:4000/;
    	proxy_set_header X-Real-IP $remote_addr;
    	proxy_set_header Host $host;
    	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    index.html 을 수정한다.

    <p style="font-family":'Tahoma';"><a href="grafana-vital" target="_blank">Patient Monitoring System (Current)</a></p>
    
  • PostgreSQL 사용

    Grafana에서 PostgreSQL을 비롯한 여러 DB도 이용할 수 있다. 이 때 SQL 구문으로 작성하는데 Format에서 Time series를 선택하지 않으면 하나의 결과만 보일 수 있다. 시간은 오름차순으로 정렬 시켜 주어야 한다.

  • Node-RED on RaspberryPi

    MP3 파일을 직접

    재생하면, 신뢰할 수 있는 알람이 될 것 같았다. 그보다는 알람이 어떨 때 발송되는지 좀 더

    우선 라즈베리파이에 npm을 설치한다.

    sudo apt install npm

    그 다음 다운 받은 Node.js 를 설치한다. 최신 버전이 아니면 Node-RED에서 추가 node가 설치 안되는 경우가 있다.

    tar -xvf node-v18.16.0-linux-armv7l.tar.xz
    cd node-v18.16.0-linux-armv7l
    cp -R * /usr/local/

    적당한 CLI 기반의 플레이어를 하나 설치한다. mpg321 를 설치했다.

    sudo apt -y install mpg321

    Node-RED를 설치한다.

    sudo npm install -g --unsafe-perm node-red
    

    모듈을 설치한다.

    cd ~/.node-red/node_modules
    npm install node-red-contrib-play-soundfile
    

    Flow 를 만든다.

    잡음이 살짝 들리는데 소리는 잘 들린다. 이어폰으로는 너무 작아서 들리지 않아 저렴한 스피커를 하나 구입하는 것이 좋을 것 같다.

    그리고 부팅할 때 실행될 수 있도록 설정해 준다.

  • Contact point 추가

    Node-RED를 이용해서 webhook 으로 알림을 보내기 위해서는 다음과 같이 설정한다.

    Add contact point를 선택한다.

    URL은 Grafana 설치된 컨테이너에서 실행 가능한 그런 경로로 입력해야 하는 것 같다. HTTP Method에 POST를 선택한다.