Skip to content

Commit

Permalink
Merge pull request #32 from HA0N1/feat/detective-search
Browse files Browse the repository at this point in the history
Feat/detective search
  • Loading branch information
bobbodaddeuk authored Jul 30, 2024
2 parents 6eff3d4 + 7a5145e commit f577448
Show file tree
Hide file tree
Showing 9 changed files with 2,673 additions and 1,074 deletions.
15 changes: 0 additions & 15 deletions config/postgresql.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,8 @@ log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'
log_rotation_age = 1d
log_rotation_size = 0
log_truncate_on_rotation = on

# 로그 레벨 설정
log_min_messages = info # 기본 로그 레벨
log_min_error_statement = error

# 에러 로그 설정
# log_directory = '/var/log/postgresql/error'
# log_filename = 'postgresql-error-%Y-%m-%d_%H%M%S.log'
# log_min_messages = error

# 정보 로그 설정
# log_directory = '/var/log/postgresql'
# log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'
# log_min_messages = info

# 디버그 로그 설정
# log_directory = '/var/log/postgresql/debug'
# log_filename = 'postgresql-debug-%Y-%m-%d_%H%M%S.log'
# log_min_messages = debug5
listen_addresses = '*'
15 changes: 15 additions & 0 deletions config/prometheus-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'prometheus'
scrape_interval: 1m
static_configs:
- targets: ['localhost:9090']

- job_name: 'node'
static_configs:
- targets: ['node-exporter:9100']

- job_name: 'postgres'
static_configs:
- targets: ['postgres-exporter:9187']
20 changes: 9 additions & 11 deletions config/promtail-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,24 @@ clients:
- url: http://loki:3100/loki/api/v1/push

scrape_configs:
- job_name: postgres_log_info
- job_name: postgres_log
static_configs:
- targets:
- localhost
labels:
job: postgres_info
__path__: ./logs/postgres-log/info/*.log

- job_name: postgres_log_error
job: postgres
__path__: ./logs/postgres-log/*.log
- job_name: app_info_log
static_configs:
- targets:
- localhost
labels:
job: postgres_error
__path__: ./logs/postgres-log/error/*.log

- job_name: postgres_log_debug
job: winston
__path__: ./logs/app-log/info/*.log
- job_name: app_error_log
static_configs:
- targets:
- localhost
labels:
job: postgres_debug
__path__: ./logs/postgres-log/debug/*.log
job: winston
__path__: ./logs/app-log/error/*.log
51 changes: 51 additions & 0 deletions config/winston.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { WinstonModuleOptions } from 'nest-winston';
import * as winston from 'winston';
import DailyRotateFile from 'winston-daily-rotate-file';

export const winstonConfig: WinstonModuleOptions = {
level: process.env.NODE_ENV === 'production' ? 'info' : 'debug',
transports: [
// 콘솔 로그
// new winston.transports.Console({
// format: winston.format.combine(
// winston.format.timestamp(),
// winston.format.colorize(),
// winston.format.simple(),
// ),
// }),
// 일반 로그 파일
new DailyRotateFile({
filename: './logs/app-log/info/application-%DATE%.log',
datePattern: 'YYYY-MM-DD',
zippedArchive: true,
maxSize: '20m',
maxFiles: '14d',
format: winston.format.combine(winston.format.timestamp(), winston.format.json()),
level: 'info',
}),
// 에러 로그 파일
new DailyRotateFile({
filename: './logs/app-log/error/error-%DATE%.log',
datePattern: 'YYYY-MM-DD',
zippedArchive: true,
maxSize: '20m',
maxFiles: '14d',
format: winston.format.combine(winston.format.timestamp(), winston.format.json()),
level: 'error',
}),
],
// 예외 처리 (추후 수정)
// exceptionHandlers: [
// new DailyRotateFile({
// filename: './logs/exceptions/exceptions-%DATE%.log',
// datePattern: 'YYYY-MM-DD',
// zippedArchive: true,
// maxSize: '20m',
// maxFiles: '14d',
// format: winston.format.combine(
// winston.format.timestamp(),
// winston.format.json()
// ),
// }),
// ],
};
71 changes: 38 additions & 33 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ services:
- ./logs:/logs
- ./logs/postgres-log:/var/log/postgresql
restart: always
depends_on:
- prometheus
networks:
- loki

Expand Down Expand Up @@ -63,40 +65,43 @@ services:
networks:
- loki

# prometheus:
# container_name: prometheus
# image: prom/prometheus:latest
# command:
# - '--config.file=/etc/prometheus/prometheus.yaml'
# volumes:
# - ./config/prometheus-config.yaml:/etc/prometheus/prometheus-config.yaml
# - ./prometheus-data:/prometheus
# ports:
# - '9090:9090'
# restart: always
# networks:
# - loki
prometheus:
container_name: prometheus
image: prom/prometheus:latest
command:
- '--config.file=/etc/prometheus/prometheus.yaml'
volumes:
- ./config/prometheus-config.yaml:/etc/prometheus/prometheus.yaml
- ./prometheus-data:/prometheus
ports:
- '9090:9090'
restart: always
networks:
- loki

volumes:
postgres-data:
loki:
grafana-data:
# prometheus-data:
POSTGRES_DB: ${POSTGRES_NAME}
node_exporter:
image: prom/node-exporter:latest
container_name: node-exporter
volumes:
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /:/rootfs:ro
command:
- '--path.procfs=/host/proc'
- '--path.rootfs=/rootfs'
- '--path.sysfs=/host/sys'
- '--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)'
expose:
- 9100
networks:
- loki

redis:
image: redis:latest
restart: always
postgres_exporter:
image: wrouesnel/postgres_exporter:latest
container_name: postgres-exporter
environment:
DATA_SOURCE_NAME: 'postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres/${POSTGRES_DB}?sslmode=disable'
ports:
- '6379:6379'
- '9187:9187'
networks:
- mynetwork
healthcheck:
test: ['CMD', 'redis-cli', 'ping']
interval: 30s
timeout: 10s
retries: 5

networks:
mynetwork: # 네트워크 정의 추가
driver: bridge
- loki
Loading

0 comments on commit f577448

Please sign in to comment.