• loki+promtail入门级部署


    环境:基于docker compose部署loki+promtail服务,用于采集日志信息。已有现成的grafana服务,故此处部署为囊括grafana

    1.docker-compose.yml配置文件

    version: '2'
    services:
      loki:
        image: grafana/loki
        container_name: loki
        restart: always
        ports:
          - "3100:3100"
        volumes:
          - /home/dockerfile/loki/loki-local-config.yaml:/etc/loki/loki-local-config.yaml
        command: -config.file=/etc/loki/loki-local-config.yaml
    
      promtail:
        image: grafana/promtail
        container_name: promtail
        restart: always
        volumes:
          - /home/dockerfile/loki/promtail-docker-config.yaml:/etc/promtail/promtail-docker-config.yaml
        command:
          -config.file=/etc/promtail/promtail-docker-config.yaml

    2.loki-local-config.yaml配置文件(路径:/home/dockerfile/loki。根据实际情况存放即可)

    auth_enabled: false
    
    server:
      http_listen_port: 3100
    
    ingester:
      lifecycler:
        address: 127.0.0.1
        ring:
          kvstore:
            store: inmemory
          replication_factor: 1
        final_sleep: 0s
      chunk_idle_period: 5m
      chunk_retain_period: 30s
    
    schema_config:
      configs:
      - from: 2018-04-15
        store: boltdb
        object_store: filesystem
        schema: v9
        index:
          prefix: index_
          period: 168h
    
    storage_config:
      boltdb:
        directory: /tmp/loki/index
    
      filesystem:
        directory: /tmp/loki/chunks
    
    limits_config:
      enforce_metric_name: false
      reject_old_samples: true
      reject_old_samples_max_age: 168h
    
    chunk_store_config:
      max_look_back_period: 0
    
    table_manager:
      chunk_tables_provisioning:
        inactive_read_throughput: 0
        inactive_write_throughput: 0
        provisioned_read_throughput: 0
        provisioned_write_throughput: 0
      index_tables_provisioning:
        inactive_read_throughput: 0
        inactive_write_throughput: 0
        provisioned_read_throughput: 0
        provisioned_write_throughput: 0
      retention_deletes_enabled: false
      retention_period: 0
    3.promtail-docker-config.yaml配置文件(路径:/home/dockerfile/loki。根据自身实际情况存放)
    server:
      http_listen_port: 0
      grpc_listen_port: 0
    
    positions:
      filename: /etc/promtail/positions.yaml   # 游标记录上一次同步位置
      sync_period: 10s #10秒钟同步一次
    
    clients:
      - url: http://loki:3100/loki/api/v1/push
    
    scrape_configs:
    - job_name: test-java-log
      static_configs:
      - targets:
          - localhost
        labels:
          job: content-cloud-test
          app: content-cloud-test
          __path__: /opt/content-cloud/webapi/logs/*log   # docker运行时已经把宿主机的目录 /opt/ 映射给了promtail 容器的 /opt/,所以这个地方可以直接访问log文件

    4.在grafana中,添加datasource-->loki

    5.通过grafana的explore即可查看loki日志。效果图

     
  • 相关阅读:
    nacos+Seata+Mybatis plus 教程
    快速排序 #java实现
    高内聚,低耦合
    整合Alibaba Sentinel 教程
    执行 aptget update 时错误 由于没有公钥,无法验证下列签名: NO_PUBKEY F76221572C52609D
    上飞机https://zhuzhu12.xyz/link/8YFX1tSR3sy3Wj2S?clash=1
    Ubuntu安装MongoDB
    指针为什么有数据类型?
    很强!Mybatis plus 学习教程 “手写SQL配置” “Mapper多参数传参” + 坑点说明
    自动清理内存 #最强,让电脑不卡的神器#最有用
  • 原文地址:https://www.cnblogs.com/danny-djy/p/13816423.html
Copyright © 2020-2023  润新知