monitoringloggingobservabilitydevops
모니터링과 로깅 - 프로덕션 시스템 관찰
조회 0
프로덕션 시스템의 모니터링과 로깅은 안정적인 서비스를 운영하는 핵심입니다.
이 글에서는 메트릭 수집, 로그 관리, 알림 설정 방법을 정리합니다.
1. 메트릭 수집
// Prometheus 스타일 메트릭
const httpRequestDuration = new promClient.Histogram({
name: "http_request_duration_seconds",
help: "HTTP request duration",
});
app.use((req, res, next) => {
const start = Date.now();
res.on("finish", () => {
httpRequestDuration.observe((Date.now() - start) / 1000);
});
next();
});
2. 로깅
const winston = require("winston");
const logger = winston.createLogger({
level: "info",
format: winston.format.json(),
transports: [
new winston.transports.File({ filename: "error.log", level: "error" }),
new winston.transports.File({ filename: "combined.log" }),
],
});