[Grafana] Loki & Promtail 설치

91Savage·2023년 5월 3일
0

Grafana

목록 보기
2/2

Loki

[Metrics 받는 서버]

  • 도커 이미지 다운로드
    docker pull grafana/loki

  • Loki 설치 경로 생성
    mkdir /etc/loki

  • Loki yaml 다운로드
    cd /etc/loki
    wget https://raw.githubusercontent.com/grafana/loki/v2.8.0/cmd/loki/loki-local-config.yaml -O loki-config.yaml

  • Loki 설치
    docker run --name loki -d -v $(pwd):/mnt/config -p 3100:3100 grafana/loki:2.8.0 -config.file=/mnt/config/loki-config.yaml
    (config.yaml 을 수동으로 경로를 지정해서 설치해줌)

  • Loki 설정
    vim /etc/loki/loki-config.yaml

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://grafana.com/docs/loki/latest/installation/docker] 참고

Promtail

  • 도커 이미지 다운로드
    docker pull grafana/promtail

  • promtail 설치 경로 생성
    mkdir /etc/promtail

  • promtail yaml 다운로드
    cd /etc/promtail
    wget https://raw.githubusercontent.com/grafana/loki/v2.8.0/clients/cmd/promtail/promtail-docker-config.yaml -O promtail-config.yaml

  • promtail 설치
    docker run --name promtail -d -v $(pwd):/mnt/config -v /var/log:/var/log grafana/promtail:2.8.0 -config.file=/mnt/config/promtail-config.yaml
    (config.yaml 을 수동으로 경로를 지정해서 설치해줌)

  • promtail 설정
    vim /etc/promtail/promtail-config.yaml

server:
  http_listen_port: 9080
  grpc_listen_port: 0

positions:
  filename: /tmp/positions.yaml

clients:
  - url: http://3.39.11.86:3100/loki/api/v1/push

scrape_configs:
- job_name: system
  static_configs:
  - targets:
      - localhost
    labels:
      job: varlogs
      __path__: /var/log/*log

0개의 댓글