한 번 로컬에서 테스트를 진행해볼 예정
24.03.12
이 사진은 offical docs에서 제공하는 get started에 나오는 example 구조도 이다. 이를 그대로 한 번 적용을 해보는 과정을 거칠 예정이다.
version: '3'
services:
dingding_framecapture:
user: user
build:
context: .
dockerfile : ./Dockerfile
container_name: dd_fc
volumes:
- ./workspace:/opt/workspace
- /nas/video:/opt/video
- /nas/backdata:/opt/backdata
- /nas/block_frame:/opt/block_frame
- /nas/stt_result:/opt/stt_result
- /nas/frame_captured:/opt/frame_captured
- /web/captured_frame:/opt/captured_frame
- ./logs/:/opt/logs
working_dir: /opt/workspace
entrypoint: uvicorn app:app --host 0.0.0.0 --port 7891 --reload
environment:
- PYTHONUNBUFFERED=1
# - CUDA_VISIBLE_DEVICES="0"
ports:
- "7891:7891"
deploy:
resources:
limits:
cpus: '16'
reservations:
cpus: '12'
loki:
image: grafana/loki:2.9.4
ports:
- "3100:3100"
volumes:
- ./loki-config.yaml:/mnt/config/loki-config.yaml
command: -config.file=/mnt/config/loki-config.yaml
promtail:
image: grafana/promtail:2.9.2
volumes:
- ./promtail-config.yaml:/mnt/config/promtail-config.yaml
- ./logs/:/var/log
command: -config.file=/mnt/config/promtail-config.yaml
depends_on:
- loki
links:
- loki
volumes:
logs:
auth_enabled: false
server:
http_listen_port: 3100
grpc_listen_port: 9096
common:
instance_addr: 127.0.0.1
path_prefix: /tmp/loki
storage:
filesystem:
chunks_directory: /tmp/loki/chunks
rules_directory: /tmp/loki/rules
replication_factor: 1
ring:
kvstore:
store: inmemory
query_range:
results_cache:
cache:
embedded_cache:
enabled: true
max_size_mb: 100
schema_config:
configs:
- from: 2020-10-24
store: boltdb-shipper
object_store: filesystem
schema: v11
index:
prefix: index_
period: 24h
ruler:
alertmanager_url: <http://localhost:9093>
# By default, Loki will send anonymous, but uniquely-identifiable usage and configuration
# analytics to Grafana Labs. These statistics are sent to <https://stats.grafana.org/>
#
# Statistics help us better understand how Loki is used, and they show us performance
# levels for most users. This helps us prioritize features and documentation.
# For more information on what's sent, look at
# <https://github.com/grafana/loki/blob/main/pkg/usagestats/stats.go>
# Refer to the buildReport method to see what goes into a report.
#
# If you would like to disable reporting, uncomment the following lines:
#analytics:
# reporting_enabled: false
server:
http_listen_port: 9080
grpc_listen_port: 0
positions:
filename: /tmp/positions.yaml
clients:
- url: <http://loki:3100/loki/api/v1/push>
scrape_configs:
- job_name: system
static_configs:
- targets:
- localhost
labels:
job: varlogs
__path__: /var/log/*log
@app.on_event("startup")
async def startup_event():
logger = logging.getLogger("uvicorn.access")
fileHandler = logging.FileHandler(f'/opt/logs/dd-fc.log' ,mode = "a")
logger.addHandler(fileHandler)
WAS와 promtail을 한 컨테이너에서 구동하는 것을 많이 보긴 했는데, 우선 loki가 제공해줬던 기본 툴에서도 따로 제공을 했었고, 로그를 전달하는 주체와 로그를 쌓는 주체가 합쳐지면 문제가 생겼을 때 관리하기 좀 귀찮을 것 같아서 의존성을 분리하는 방향으로 디자인을 했다.
헌데 새로운 디자인 방향도 제안을 해주셨는데, 이렇게 된다면 하나만 죽어도 log가 쌓이지 않는 문제가 발생할 수 있다. 그래서 로그 자체에 오류가 생길 수도 있다는 점이다. 항상 작은 단위로 쪼개려고만 노력했지 이런 생각도 있다는 것이 신기했다.