Alert History API
개요
Alert History API는 발생한 모든 Alert의 이력을 페이징 기반으로 조회하고, 심각도별/소스별 통계를 제공합니다.
기본 정보
| 항목 | 값 |
|---|---|
| 기본 경로 | /api/v1.0/alert-history |
| 인증 | 불필요 |
| 버전 | v1.0 |
엔드포인트 요약
| 메서드 | 경로 | 설명 |
|---|---|---|
| GET | /api/v1.0/alert-history | Alert 이력 페이징 조회 |
| GET | /api/v1.0/alert-history/{id} | Alert 상세 조회 |
| GET | /api/v1.0/alert-history/stats/severity | 심각도별 통계 |
| GET | /api/v1.0/alert-history/stats/source | 소스별 통계 |
상세 엔드포인트
GET /api/v1.0/alert-history
Alert 히스토리 목록을 페이징 조회합니다. 심각도, 소스, 날짜 필터링을 지원합니다.
요청
| 파라미터 | 타입 | 필수 | 설명 |
|---|---|---|---|
| page | int | N | 페이지 번호 (기본값: 1) |
| pageSize | int | N | 페이지 크기 (기본값: 50) |
| severity | AlertSeverity? | N | 심각도 필터 (Info, Warning, Critical) |
| source | string? | N | 소스 필터 (부분 일치) |
| startDate | DateTime? | N | 시작 날짜 (UTC) |
| endDate | DateTime? | N | 종료 날짜 (UTC) |
응답
{
"records": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"timestamp": "2026-02-09T10:30:00Z",
"severity": "Warning",
"source": "Equipment-01",
"title": "Motor Overload",
"description": "Motor current exceeded 80% threshold",
"labels": {
"equipmentId": "Equipment-01",
"tagId": "Motor.Current"
}
}
],
"totalCount": 1250,
"page": 1,
"pageSize": 50,
"totalPages": 25
}
응답 코드
| 코드 | 설명 |
|---|---|
| 200 | 성공 |
| 400 | 잘못된 파라미터 |
| 500 | 서버 내부 오류 |
GET /api/v1.0/alert-history/{id}
특정 Alert의 상세 정보를 조회합니다.
요청
| 파라미터 | 타입 | 필수 | 설명 |
|---|---|---|---|
| id | string | Y | Alert ID (GUID, 경로 파라미터) |
응답
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"timestamp": "2026-02-09T10:30:00Z",
"severity": "Warning",
"source": "Equipment-01",
"title": "Motor Overload",
"description": "Motor current exceeded 80% threshold",
"labels": {
"equipmentId": "Equipment-01",
"tagId": "Motor.Current",
"threshold": "80"
},
"annotations": {
"summary": "Motor 과부하 경보",
"runbook": "https://docs.example.com/runbooks/motor-overload"
}
}
응답 코드
| 코드 | 설명 |
|---|---|
| 200 | 성공 |
| 404 | Alert를 찾을 수 없음 |
| 500 | 서버 내부 오류 |
GET /api/v1.0/alert-history/stats/severity
심각도별 Alert 통계를 조회합니다.
요청
| 파라미터 | 타입 | 필수 | 설명 |
|---|---|---|---|
| startDate | DateTime? | N | 시작 날짜 (UTC) |
| endDate | DateTime? | N | 종료 날짜 (UTC) |
응답
[
{
"severity": "Critical",
"count": 15
},
{
"severity": "Warning",
"count": 42
},
{
"severity": "Info",
"count": 128
}
]
응답 코드
| 코드 | 설명 |
|---|---|
| 200 | 성공 |
| 500 | 서버 내부 오류 |
GET /api/v1.0/alert-history/stats/source
소스별 Alert 통계를 조회합니다.
요청
| 파라미터 | 타입 | 필수 | 설명 |
|---|---|---|---|
| startDate | DateTime? | N | 시작 날짜 (UTC) |
| endDate | DateTime? | N | 종료 날짜 (UTC) |
응답
[
{
"source": "Equipment-01",
"count": 85
},
{
"source": "Sensor-05",
"count": 62
},
{
"source": "System",
"count": 38
}
]
응답 코드
| 코드 | 설명 |
|---|---|
| 200 | 성공 |
| 500 | 서버 내부 오류 |
DTO 정의
AlertHistoryRecord
| 속성 | 타입 | 설명 |
|---|---|---|
| id | string | Alert 고유 식별자 (GUID) |
| timestamp | DateTime | 발생 시간 (UTC) |
| severity | AlertSeverity | 심각도 (Info, Warning, Critical) |
| source | string | Alert 소스 (장비/센서 ID) |
| title | string | Alert 제목 |
| description | string | Alert 상세 설명 |
| labels | Dictionary<string, string> | Alert 라벨 (메타데이터) |
| annotations | Dictionary<string, string>? | Alert 주석 (선택) |
AlertSeverity (Enum)
public enum AlertSeverity
{
Info = 0,
Warning = 1,
Critical = 2
}
사용 예제
C# (HttpClient)
using System.Net.Http.Json;
var client = new HttpClient { BaseAddress = new Uri("https://localhost:5001") };
// 페이징 조회 (최근 24시간, Warning 이상)
var response = await client.GetFromJsonAsync<AlertHistoryResponse>(
"/api/v1.0/alert-history?page=1&pageSize=20&severity=Warning&startDate=2026-02-08T00:00:00Z");
Console.WriteLine($"Total: {response.TotalCount}, Page: {response.Page}/{response.TotalPages}");
foreach (var record in response.Records)
{
Console.WriteLine($"[{record.Severity}] {record.Title} - {record.Timestamp:u}");
}
// Alert 상세 조회
var detail = await client.GetFromJsonAsync<AlertHistoryRecord>(
"/api/v1.0/alert-history/550e8400-e29b-41d4-a716-446655440000");
// 심각도별 통계
var severityStats = await client.GetFromJsonAsync<List<SeverityStat>>(
"/api/v1.0/alert-history/stats/severity?startDate=2026-02-01T00:00:00Z");
curl
# 페이징 조회
curl -X GET "https://localhost:5001/api/v1.0/alert-history?page=1&pageSize=20&severity=Warning"
# Alert 상세 조회
curl -X GET "https://localhost:5001/api/v1.0/alert-history/550e8400-e29b-41d4-a716-446655440000"
# 심각도별 통계
curl -X GET "https://localhost:5001/api/v1.0/alert-history/stats/severity?startDate=2026-02-01T00:00:00Z"
# 소스별 통계
curl -X GET "https://localhost:5001/api/v1.0/alert-history/stats/source"
JavaScript (Fetch)
// 페이징 조회
const response = await fetch(
'https://localhost:5001/api/v1.0/alert-history?page=1&pageSize=20'
).then(res => res.json());
console.log(`Total Alerts: ${response.totalCount}`);
response.records.forEach(alert => {
console.log(`[${alert.severity}] ${alert.title}`);
});
// 심각도별 통계 차트 데이터
const stats = await fetch(
'https://localhost:5001/api/v1.0/alert-history/stats/severity'
).then(res => res.json());
// Chart.js 등으로 시각화
const chartData = {
labels: stats.map(s => s.severity),
data: stats.map(s => s.count)
};
페이징 정보
페이징 응답은 다음 정보를 포함합니다:
totalCount: 전체 레코드 수page: 현재 페이지 번호 (1부터 시작)pageSize: 페이지당 레코드 수totalPages: 전체 페이지 수 (자동 계산)
주의사항
startDate와endDate는 UTC 시간대로 전달해야 합니다.- 페이지 크기는 최대 100으로 제한됩니다.
- 통계 API는 조건에 맞는 전체 데이터를 메모리에서 처리하므로, 날짜 범위를 적절히 제한하세요.
관련 API
- Alarm API - 활성 알람 관리
- Alert Silence API - Alert 음소거 관리
- Alertmanager API - Prometheus Alertmanager 연동