当前位置: 首页 > article >正文

轻量级日志管理系统promtail+loki+grafana部署流程

一、下载

promtail+loki+grafana压缩包

"https://github.com/grafana/loki/releases/download/v1.5.0/loki-linux-amd64.zip" 
"https://github.com/grafana/loki/releases/download/v1.5.0/promtail-linux-amd64.zip"
https://dl.grafana.com/enterprise/release/grafana-enterprise-8.3.3.linux-amd64.tar.gz

二、创建安装目录

  • 以下目录用来存放各个组件压缩包的解压文件和配置
    /usr/local/logsCollect/loki
    /usr/local/logsCollect/grafana
    /usr/local/logsCollect/promtail
  • 以下目录用来文件存储和索引存储
    /data/loki/chunks
    /data/loki/index

三、安装Loki

  1. 解压loki-linux-amd64.zip
  2. 修改配置loki-local-config.yaml

获取官方通用配置wget https://raw.githubusercontent.com/grafana/loki/master/cmd/loki/loki-local-config.yaml

官方文档https://grafana.com/docs/loki/latest/installation/local/

auth_enabled: false
server:
  http_listen_port: 8094
ingester:
  lifecycler:
    address: 192.168.244.128 #日志服务器ip,即本机地址
    ring:
      kvstore:
        store: inmemory
      replication_factor: 1
    final_sleep: 0s
  chunk_idle_period: 5m
  chunk_retain_period: 30s
schema_config:
  configs:
  - from: 2024-04-01
    store: boltdb
    object_store: filesystem
    schema: v11
    index:
      prefix: index_
      period: 168h   #每张表的时间范围7天
storage_config:
  boltdb:
    directory: /data/loki/index   #索引文件存储地址
  filesystem:
    directory: /data/loki/chunks  #块存储地址
limits_config:
  enforce_metric_name: false
  reject_old_samples: true
  reject_old_samples_max_age: 168h
chunk_store_config:
# 最大可查询历史日期 7天,这个时间必须是schema_config中的period的倍数,否则报错。
  max_look_back_period: 168h
# 表的保留期7天
table_manager:
  retention_deletes_enabled: true
  retention_period: 168h
  1. 启动
  • 命令行启动
    ./loki-linux-amd64 --config.file=loki-local-config.yaml
  • 后台运行
    nohup ./loki-linux-amd64 --config.file=loki-local-config.yaml > server.log 2>&1 &
  • 启动脚本
#!/bin/bash
nohup ./loki-linux-amd64 -config.file=./loki-local-config.yaml >./server.log 2>&1 &
echo "$!" > pid
  • 结束运行脚本
#!/bin/bash
kill -9 `cat pid`
echo "关闭成功!"

四、安装Grafana

  1. 解压grafana-enterprise-8.3.3.linux-amd64.tar.gz(tar -xzvf )。注意conf/defaults.ini为grafana的配置文件。
  2. 修改配置conf/defaults.ini

http_port 默认为3000

  1. 启动
  • 脚本运行
#!/bin/bash
nohup ./bin/grafana-server >./server.log 2>&1 &
echo "$!" > pid
  • 结束运行脚本
#!/bin/bash
kill -9 `cat pid`
echo "关闭成功!"

五、安装Promtail

  1. 解压promtail-linux-amd64.zip
  2. 配置promtail.yaml

获取通用配置wget https://raw.githubusercontent.com/grafana/loki/main/clients/cmd/promtail/promtail-local-config.yaml

官方文档https://grafana.com/docs/loki/latest/installation/local/

server:
  http_listen_port: 9080
  grpc_listen_port: 0

positions:
  filename: ./positions.yaml

clients:
  - url: http://192.168.244.128:8094/loki/api/v1/push #日志服务器loki地址和端口

scrape_configs:
#ucenter1
 - job_name: test-log
   static_configs:
   - targets:
       - 192.168.244.128 # 日志所在的服务器
   - labels:
      job: log1
      host: 10.60.134.60
      __path__: /app/logs/info.log  #本机日志路径,支持通配符

六、浏览器进入Grafana

192.168.244.128:3000 默认账号密码admin/admin


http://www.kler.cn/a/569923.html

相关文章:

  • PHP简介
  • 浏览器多实例项目的隔离方案
  • 阿里云 对象存储服务
  • 亚马逊新品推广革命:如何用DeepBI的AI智能系统实现从0到爆单的跨越式增长?
  • Wireshark的OSPF报文抓包和分析(单区域ospf实验)
  • 1114棋盘问题acwing(深度优先搜索)
  • ollama查看模型日志
  • 【Vue CLI脚手架开发】——2.ref属性
  • Arcgis中添加脚本工具箱
  • 基于nginx的灰度发布解决方案
  • AIC8800---编译环境搭建
  • 深度学习文本生成:从 GPT 到 Transformers
  • HTTP/1.1 和 HTTP/2 的区别,HTTP/2 有哪些新特性?
  • 基于springboot+vue美食与健康分享推广网站
  • 手机投屏电脑 Scrcpy
  • 【Elasticsearch】自定义内置的索引生命周期管理(ILM)策略。
  • 【蓝桥杯集训·每日一题2025】 AcWing 5439. 农夫约翰真的种地 python
  • 【Swift 算法实战】判断数组中是否存在重复元素
  • 【PyQt5】python可视化开发:PyQt5介绍,开发环境搭建快速入门
  • 通过Python编程语言实现机器学习小项目教程案例