menu 学习笔记
search self_improvement
目录

Prometheus 监控方案学习笔记(六):Loki 的安装和配置

huty
huty 2022年12月02日  ·  阅读 1,266

Loki 的安装和配置

Docker Compose 方式

  1. 创建相关目录
mkdir -p /apps/loki/conf
  1. 编辑 docker-compose.yml 文件
vim /apps/loki/docker-compose.yml
version: "3"
services:
  loki:
    image: grafana/loki:2.6.1
    container_name: prometheus-loki
    hostname: loki
    restart: always
    volumes:
      - /apps/loki/conf/loki-config.yaml:/etc/loki/loki-config.yaml
    ports:
      - 3100:3100
    command: "-config.file=/etc/loki/loki-config.yaml"
networks:
  default:
    external:
      name: prometheus
  1. 编辑 loki-config.yaml 文件
vim /apps/loki/conf/loki-config.yaml
auth_enabled: false

server:
  http_listen_port: 3100
  grpc_listen_port: 9096

common:
  path_prefix: /tmp/loki
  storage:
    filesystem:
      chunks_directory: /tmp/loki/chunks
      rules_directory: /tmp/loki/rules
  replication_factor: 1
  ring:
    instance_addr: 127.0.0.1
    kvstore:
      store: inmemory

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
  1. 配置 docker 网段 prometheus
    检查是否存在 prometheus 网段:
docker network list

若不存在,则创建:

docker network create prometheus --subnet 10.21.22.0/24
  1. 启动 Loki 容器
cd /apps/loki
docker-compose up -d
  1. 检查 Loki 容器状态、查看 Loki 容器日志
cd /apps/loki
docker-compose ps
docker-compose logs -f

评论已关闭