본문으로 건너뛰기

Alert History API

개요

Alert History API는 발생한 모든 Alert의 이력을 페이징 기반으로 조회하고, 심각도별/소스별 통계를 제공합니다.

기본 정보

항목
기본 경로/api/v1.0/alert-history
인증불필요
버전v1.0

엔드포인트 요약

메서드경로설명
GET/api/v1.0/alert-historyAlert 이력 페이징 조회
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 히스토리 목록을 페이징 조회합니다. 심각도, 소스, 날짜 필터링을 지원합니다.

요청

파라미터타입필수설명
pageintN페이지 번호 (기본값: 1)
pageSizeintN페이지 크기 (기본값: 50)
severityAlertSeverity?N심각도 필터 (Info, Warning, Critical)
sourcestring?N소스 필터 (부분 일치)
startDateDateTime?N시작 날짜 (UTC)
endDateDateTime?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의 상세 정보를 조회합니다.

요청

파라미터타입필수설명
idstringYAlert 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성공
404Alert를 찾을 수 없음
500서버 내부 오류

GET /api/v1.0/alert-history/stats/severity

심각도별 Alert 통계를 조회합니다.

요청

파라미터타입필수설명
startDateDateTime?N시작 날짜 (UTC)
endDateDateTime?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 통계를 조회합니다.

요청

파라미터타입필수설명
startDateDateTime?N시작 날짜 (UTC)
endDateDateTime?N종료 날짜 (UTC)

응답

[
{
"source": "Equipment-01",
"count": 85
},
{
"source": "Sensor-05",
"count": 62
},
{
"source": "System",
"count": 38
}
]

응답 코드

코드설명
200성공
500서버 내부 오류

DTO 정의

AlertHistoryRecord

속성타입설명
idstringAlert 고유 식별자 (GUID)
timestampDateTime발생 시간 (UTC)
severityAlertSeverity심각도 (Info, Warning, Critical)
sourcestringAlert 소스 (장비/센서 ID)
titlestringAlert 제목
descriptionstringAlert 상세 설명
labelsDictionary<string, string>Alert 라벨 (메타데이터)
annotationsDictionary<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: 전체 페이지 수 (자동 계산)

주의사항

  • startDateendDate는 UTC 시간대로 전달해야 합니다.
  • 페이지 크기는 최대 100으로 제한됩니다.
  • 통계 API는 조건에 맞는 전체 데이터를 메모리에서 처리하므로, 날짜 범위를 적절히 제한하세요.

관련 API