디스크 사용량이 75%이상일때로 수정하여 진행 (node_exporter의 pod eviction을 방지)

#local machine에 알림을 보내는 명령어를 실행할 서버 프로그램 설정
#alertmanager의 webhook을 처리할 로직
from flask import Flask, request
import subprocess
app = Flask(__name__)
@app.route("/alert", methods=["GET"])
def alert():
node = request.args.get("node")
usage = request.args.get("usage")
title = "🚨 Prometheus Disk Alert"
message = f"Node: {node}\nDisk Usage: {usage}%"
subprocess.run([
"notify-send",
"-u", "critical",
"-i", "dialog-error",
title,
message
])
return "ok", 200
if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000)
실행 및 테스트
#서버 실행
python alert.py
* Serving Flask app 'alert'
* Debug mode: off
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:5000
* Running on http://192.168.151.161:5000
Press CTRL+C to quit
#서버로 요청 전송
curl http://localhost:5000/alert?node=test-node&usage=75

alert 노출
'ops > kubernetes' 카테고리의 다른 글
| prometheus grafana helm chart 업그레이드 하기 (0) | 2026.01.12 |
|---|---|
| 워커노드의 disk-usage에 따라 alert발생 시키기 - 4(alert manager 설정) (0) | 2026.01.12 |
| 쿠버네티스가 클러스터의 노드에 taints를 적용하는 기준 (1) | 2026.01.12 |
| 워커노드의 disk-usage에 따라 alert발생 시키기 - 2(rule 설정) (0) | 2026.01.12 |
| 워커노드의 disk-usage에 따라 alert발생 시키기 - 1(쿼리문) (0) | 2026.01.12 |