loki + promtail + grafana 日志看板平台

一、下载

wget -c https://github.com/grafana/loki/releases/download/v2.1.0/loki-linux-amd64.zip
wget -c https://github.com/grafana/loki/releases/download/v2.1.0/promtail-linux-amd64.zip
wget -c https://dl.grafana.com/oss/release/grafana-9.0.2.linux-amd64.tar.gz
wget -c https://raw.githubusercontent.com/grafana/loki/master/cmd/loki/loki-local-config.yaml
wget -c https://raw.githubusercontent.com/grafana/loki/main/clients/cmd/promtail/promtail-local-config.yaml

二、loki

docker run -itd --privileged  \
-p 3100:3100  \
-p 9095:9095  \
-v /usr/local/docker_loki:/usr/local/loki  \
--name=loki  \
centos7_ssh:latest \
/usr/sbin/init

配置文件
cat /usr/local/docker_loki/loki-local-config.yaml |grep -vE ‘$|#’

auth_enabled: false
server:
  http_listen_port: 3100
  grpc_listen_port: 9095 #grpc监听端口,默认为9095,可直接修改
  grpc_server_max_recv_msg_size: 1572864000 #grpc最大接收消息值,默认4m
  grpc_server_max_send_msg_size: 1572864000 #grpc最大发送消息值,默认4m
ingester:
  lifecycler:
    address: 192.168.2.100 #IP地址
    ring:
      kvstore:
        store: inmemory
      replication_factor: 1
    final_sleep: 0s
  chunk_idle_period: 5m
  chunk_retain_period: 30s
  max_transfer_retries: 0
  max_chunk_age: 20m  #一个timeseries块在内存中的最大持续时间。如果timeseries运行的时间超过此时间,则当前块将刷新到存储并创建一个新块
schema_config:
  configs:
    - from: 2018-04-15
      store: boltdb
      object_store: filesystem
      schema: v11
      index:
        prefix: index_
        period: 168h
storage_config:
  boltdb:
    directory: /usr/local/loki/loki_data/index
  filesystem:
    directory: /usr/local/loki/loki_data/chunks
limits_config:
  ingestion_rate_mb: 32
  ingestion_burst_size_mb: 64
  enforce_metric_name: false
  reject_old_samples: true
  reject_old_samples_max_age: 168h
chunk_store_config:
  max_look_back_period: 168h   #回看日志行的最大时间,只适用于即时日志
table_manager:
  retention_deletes_enabled: true #日志保留周期开关,默认为false
  retention_period: 168h  #日志保留周期

启动:
docker exec -it loki cat /etc/rc.local|grep loki

nohup /usr/local/loki/loki-linux-amd64 --config.file=/usr/local/loki/loki-local-config.yaml >/usr/local/loki/nohup.out 2 >&1 &

三、promtail
配置
cat /usr/local/promtail/promtail-local-config.yaml |grep -vE ‘$|#’

server:
  http_listen_port: 9080
  grpc_listen_port: 0
positions:
  filename: /tmp/positions.yaml
clients:
  - url: http://192.168.2.100:3100/loki/api/v1/push
scrape_configs:
- job_name: java-spring
  static_configs:
  - targets:
      - 192.168.1.222-spring
    labels:
      job: 222-xx-java
      __path__: /xxx/xxx/path/*/nohup.out

启动

nohup /usr/local/promtail/promtail-linux-amd64 -config.file=/usr/local/promtail/promtail-local-config.yaml >/usr/local/promtail/nohup.out 2>& 1 &

四、grafana

wget -c https://dl.grafana.com/oss/release/grafana-9.0.2.linux-amd64.tar.gz
tar -xf grafana-9.0.2.linux-amd64.tar.gz 
mv  grafana-9.0.2  /usr/local/docker_grafana

启动

docker run -itd --privileged  -p 3000:3000  \
-v /usr/local/docker_grafana:/usr/local/grafana  \
--name=grafana  centos7_ssh:latest /usr/sbin/init

nohup /usr/local/grafana/bin/grafana-server >/usr/local/grafana/nohup.out 2>& 1 &

也可以用官网的镜像

五、使用
在这里插入图片描述

在这里插入图片描述

-------------end

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值