Skip to content

underbell/localstack-logging-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

2 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

์›น์„œ๋ฒ„ ๋กœ๊น… ํŒŒ์ดํ”„๋ผ์ธ(Centralized Logging Pipeline)์„ ๊ตฌ์ถ•

๋ชฉํ‘œ

  • nginx access log data๋ฅผ fluentd๋ฅผ ํ†ตํ•˜์—ฌ kinesis๋กœ 1๋ถ„ ๋‹จ์œ„๋กœ ์ „์†ก
  • kinesis stream์„ lambda๊ฐ€ ๋ฐ›์•„ json ํ˜•ํƒœ๋กœ ๋ณ€ํ™˜ํ•˜์—ฌ S3์— ์—…๋กœ๋“œ
  • ๋ชจ๋“  ๊ฒƒ์„ localstack์œผ๋กœ ํ™•์ธ

์‚ฌ์ „ ์ค€๋น„ - localstack, nginx, fluentd

1. kinesis-stream ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•œ fluend docker image ์ƒ์„ฑ

$ docker build -t custom-fluentd:latest .

Dockerfile ์ฐธ๊ณ 

2. Docker compose ํŒŒ์ผ ์ค€๋น„ - localstack, nginx, fluentd

version: '3'

services:
  localstack:
    container_name: "localstack"
    image: localstack/localstack
    ports:
      - "4566-4599:4566-4599"
      - "${PORT_WEB_UI-4566}:${PORT_WEB_UI-8080}"
    environment:
      - SERVICES=${SERVICES-lambda,kinesis,s3 }
      - DEBUG=${DEBUG-1 }
      - DATA_DIR=${DATA_DIR- }
      - PORT_WEB_UI=${PORT_WEB_UI- }
      - LAMBDA_EXECUTOR=${LAMBDA_EXECUTOR-docker-reuse }
      - KINESIS_ERROR_PROBABILITY=${KINESIS_ERROR_PROBABILITY- }
      - DOCKER_HOST=unix:///var/run/docker.sock
    volumes:
      - "./localstack:/tmp/localstack"
      - "/var/run/docker.sock:/var/run/docker.sock"

  nginx:
    container_name: nginx
    image: nginx:latest
    ports:
      - "80:80"
    volumes:
      - "./nginx/conf/nginx.conf:/etc/nginx/nginx.conf"
      - "./nginx/log:/var/log/nginx"

  fluentd:
    container_name: fluentd
    image: custom-fluentd:latest
    ports:
      - "24224:24224"
    volumes:
      - "./fluentd/fluent.conf:/fluentd/etc/fluent.conf"
      - "./nginx/log:/var/log/nginx"

3. docker compose up์œผ๋กœ docker ๊ตฌ๋™

MacOS : $ TMPDIR=/private$TMPDIR docker-compose up -d
Others : $ docker-compose up -d

4. localstack ๋กœ๊ทธ ํ™•์ธ ๋˜๋Š” health check ๋ฅผ ํ†ตํ•ด ์„œ๋น„์Šค ์ƒํƒœ ํ™•์ธ

http://localhost:8080/health

(Option) install LocalStack AWS CLI

$ pip install awscli-local

5. terraform ์ ์šฉ - terraform ์œผ๋กœ localstack์— ์ธํ”„๋ผ ๊ตฌ์„ฑ

  • ์ ์šฉํ•˜๊ธฐ ์œ„ํ•œ ๋ช…๋ น :
$ terraform init
$ terraform plan
$ terraform apply
  • ํ…Œ์ŠคํŠธ ํ›„ destory :
$ terraform destroy

6. nginx log ์ƒ์„ฑ ์‹œ ์ฒ˜๋ฆฌ ๋‚ด์šฉ ํ™•์ธ

$ docker logs -f localstack

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •