Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

운영 서버에 프롬테일 도입 (issue #396) #399

Closed
wants to merge 4 commits into from
Closed

Conversation

Minjoo522
Copy link
Contributor

@Minjoo522 Minjoo522 commented Aug 22, 2024

구현 요약

이 PR은 main에 머지됩니다.
운영 서버에 프롬테일을 도입합니다.
해당 PR에 포함된 파일 외 로컬에서 변경된 파일 내용은 아래와 같습니다.

⚠️ 참고 사항

  • 머지 후 모니터링 서버에서 compose.yml 다시 돌려야합니다.
  • 그라파나 설정도 머지 후 변경 필요합니다.
  • 자세한 내용은 문서 작성 예정입니다.

promtail app-config.yml

server:  
  http_listen_port: 9080  
  grpc_listen_port: 0  
  
positions:  
  filename: /tmp/positions.yaml  
  
clients:  
  - url: http://{모니터링 서버 IP 주소}:3100/loki/api/v1/push  
  
scrape_configs:  
  - job_name: app-logging  
    static_configs:  
      - targets:  
          - localhost  
        labels:  
          job: varlogs  
          __path__: /var/log/*log  
          env: prod-app

promtail nginx-config.yml

server:  
  http_listen_port: 9080  
  grpc_listen_port: 0  
  
positions:  
  filename: /tmp/positions.yaml  
  
clients:  
  - url: http://{모니터링 서버 IP 주소}:3100/loki/api/v1/push  
  
scrape_configs:  
  - job_name: nginx-logging
    static_configs:  
      - targets:  
          - localhost  
        labels:  
          job: varlogs  
          __path__: /var/log/*log  
          env: prod-nginx

모니터링 서버 compose.yml

  • 로키 설정을 조금 변경했습니다.
  loki:
    container_name: gafana-loki
    image: grafana/loki:3.0.0
    ports:
      - 3100:3100
    volumes:
      - ./loki:/loki
      - ./loki-config.yml:/mnt/config/loki-config.yml
    command:
      - config.file=/mnt/config/loki-config.yml
    restart: unless-stopped

모니터링 서버 loki-config.yml

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: tsdb
      object_store: filesystem
      schema: v13
      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/analytics/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

그라파나 datasources.yml

  • loki를 추가했습니다.
- name: Loki
  type: loki
  access: proxy 
  orgId: 1
  url: http://loki:3100
  basicAuth: false
  isDefault: true
  version: 1
  editable: false

참고한 문서

연관 이슈

이 부분을 제거하고 연관된 이슈를 아래와 같이 명시해 닫아주세요.

참고

코드 리뷰에 RCA 룰을 적용할 시 참고해주세요.

헤더 설명
R (Request Changes) 적극적으로 반영을 고려해주세요
C (Comment) 웬만하면 반영해주세요
A (Approve) 반영해도 좋고, 넘어가도 좋습니다. 사소한 의견입니다.

- common의 기본 설정을 유지하고 필요한 부분에 prod 설정을 덮어씌우기 위해 순서 변경
@Minjoo522 Minjoo522 added 🚛 백엔드 백엔드 관련 이슈 ⚒️ 기능 작업해야하는 기능 labels Aug 22, 2024
@Minjoo522 Minjoo522 self-assigned this Aug 22, 2024
Copy link
Member

@alstn113 alstn113 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다

Copy link
Member

@le2sky le2sky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생 많으셨어요 리브 👍👍

Copy link
Contributor

@robinjoon robinjoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리브 고생 많았습니다! 얼릉 적용해보고 싶네요.

Comment on lines 30 to +40
restart: always
container_name: develup-app

promtail-nginx:
image: grafana/promtail:3.0.0
volumes:
- /home/ubuntu/promtail/nginx-config.yml:/mnt/config/config.yml
- /var/log/nginx:/var/log
command:
- config.file=/mnt/config/config.yml
restart: unless-stopped
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[질문]�
application 서비스와 promtail-xxx 서비스의 restart 옵션이 서로 다르게 설정되어있는데요, 특별한 이유가 있는건가요?

@Minjoo522 Minjoo522 closed this Sep 23, 2024
@Minjoo522 Minjoo522 deleted the feat/#396 branch September 23, 2024 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚒️ 기능 작업해야하는 기능 🚛 백엔드 백엔드 관련 이슈
Projects
Status: 😎 DONE
Development

Successfully merging this pull request may close these issues.

5 participants