알림 템플릿
알림 템플릿 (Template notifications)
알림 템플릿을 사용해 알림의 제목, 메시지, 형식을 바꿀 수 있어요. Grafana는 알림 제목용 기본 템플릿(default.title)과 알림 메시지용 기본 템플릿(default.message)을 제공하며, 둘 다 일반적인 알림 세부 정보를 표시해요. 커스텀 알림 템플릿을 만들어 메시지 내용과 형식을 맞춤 설정할 수도 있어요.
출처: 문서
본문
템플릿으로 할 수 있는 예:
- 이메일의 제목이나 메시지의 제목을 개인화해요.
- 특정 라벨·어노테이션·링크를 선택하거나 생략하는 등 알림 내 텍스트를 수정해요.
- 굵게·이탤릭 스타일로 텍스트를 형식화하고 줄 바꿈을 추가하거나 제거해요.
하지만 제한 사항이 있어요. 할 수 없는 것:
- 시각적 모양 수정: 이메일 알림에 HTML이나 CSS를 추가해 시각적 변경. Slack이나 Microsoft Teams 같은 메시징 서비스에서 커스텀 블록·어댑티브 카드 추가 등 알림 디자인 변경.
- 미디어와 데이터 관리: 템플릿에 전달되는 데이터 구조나 형식 맞춤 설정 — 웹훅용 새 JSON 필드 추가나 XML 데이터 전송. 구성에서 정의된 것 외에 웹훅의 HTTP 헤더 수정, 이미지의 수·크기·위치 조정.
알림의 각 알림에 대한 summary와 description 어노테이션을 표시하는 예제:
{{ define "custom.alerts" -}}
{{ len .Alerts }} alert(s)
{{ range .Alerts -}}
{{ template "alert.summary_and_description" . -}}
{{ end -}}
{{ end -}}
{{ define "alert.summary_and_description" }}
Summary: {{.Annotations.summary}}
Status: {{ .Status }}
Description: {{.Annotations.description}}
{{ end -}}
알림 메시지는 다음과 같아요:
2 alert(s)
Summary: The database server db1 has exceeded 75% of available disk space.
Status: firing
Description: This alert fires when a database server is at risk of running out of disk space. You should take measures to increase the maximum available disk space as soon as possible to avoid possible corruption.
Summary: The web server web1 has been responding to 5% of HTTP requests with 5xx errors for the last 5 minutes.
Status: resolved
Description: This alert fires when a web server responds with more 5xx errors than is expected. This could be an issue with the web server or a backend service.
Note: 알림 템플릿에 알림 인스턴스에 대한 추가 정보를 넣지 마세요 — 이 정보는 알림 메시지에서만 보이거든요. 대신 어노테이션 또는 라벨로 정보를 알림에 직접 추가해 Grafana의 알림 상태와 알림 히스토리에서도 보이게 하고, 새 알림 어노테이션·라벨을 템플릿에서 출력하세요.
연락처에 알림 템플릿 선택
알림 템플릿은 이메일이나 Slack 같은 특정 연락처 통합에 묶이지 않으며, 같은 템플릿을 여러 연락처에서 공유할 수 있어요. 알림 템플릿은 연락처에 지정되어 연락처 통합에 전송되는 알림 메시지를 결정해요. 기본적으로 Grafana는 {{define "default.title"}}과 {{define "default.message"}} 같은 기본 템플릿을 제공해 알림 메시지를 형식화해요.
Grafana Cloud AI 생성 템플릿
Grafana Cloud 사용자는 내장 AI 도구로 적절한 알림 템플릿 언어로 템플릿을 생성할 수 있어요:
- Alerting -> Contact points로 이동해요.
- Notification Templates 탭을 클릭한 뒤 + New notification template 버튼을 클릭해요.
- 템플릿 이름을 정해요.
- Template group 섹션에서 Generate with AI 버튼을 클릭해요.
- AI 도구에 프롬프트를 제공하거나 예제 프롬프트 중 하나를 선택해 필요하면 편집해요.
- Save를 클릭해요.
더 알아보기
알림 템플릿 작성에 대한 자세한 내용:
- Select, create, and preview a notification template
- Notification template reference
- Notification template examples
Tip: 템플릿의 실용 예제는 "Getting Started with Templating" 튜토리얼을 참고하세요.