Promtail+Loki+Grafana监控日志

1.安装Promtail和Loki

链接: https://pan.baidu.com/s/1keC4CWfE7EK5n6RjZdmhgA?pwd=6666 提取码: 6666

解压:unzip .....

没有unzip请安装:yum install -y unzip

2.下载Promtail和Loki的配置文件

wget https://raw.githubusercontent.com/grafana/loki/main/cmd/loki/loki-local-config.yaml

wget https://raw.githubusercontent.com/grafana/loki/main/clients/cmd/promtail/promtail-local-config.yaml

3.修改配置文件

promtail-local-config.yaml

复制代码
#promtail-local-config.yaml
server:
  http_listen_port: 9080  #promtail访问地址
  grpc_listen_port: 0

positions:
  filename: /tmp/positions.yaml

clients:
  - url: http://192.168.111.106:3100/loki/api/v1/push  #推送到Loki服务器的地址

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

#以上是简单的配置如需了解配置,请自行搜索

loki-local-config.yaml

复制代码
#loki-local.config.yaml

auth_enabled: false
server:
  http_listen_port: 3100
ingester:
  lifecycler:
    address: 192.168.111.106 
    ring:
      kvstore:
        store: inmemory
      replication_factor: 1
    final_sleep: 0s
  chunk_idle_period: 5m
  chunk_retain_period: 30s
schema_config:
  configs:
  - from: 2025-04-29
    store: boltdb
    object_store: filesystem
    schema: v11
    index:
      prefix: index_
      period: 168h   
storage_config:
  boltdb:
    directory: /data/loki/index   
  filesystem:
    directory: /data/loki/chunks  



#以上是简单的配置如需了解配置,请自行搜索

4.运行Primtail和Loki

后台运行重定向

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

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

运行情况

promtial拉取到数据

查看Promtail是否成功推送到Loki

5.登录到Grafana客户端

6.日志查询

相关推荐
learndiary11 分钟前
2026.03.12~2026.03.19制作的共7个视频及简介
linux·视频·学习日记小店
JiMoKuangXiangQu14 分钟前
Linux:ARM64 中断处理简析
linux·arm64 中断
小生不才yz27 分钟前
【Makefile 专家之路 | 函数篇】11. 终极奥义:eval 函数——动态生成规则的“核武器”
linux
皮卡蛋炒饭.32 分钟前
进程得控制
linux·运维·服务器
YMWM_1 小时前
Install pyrealsense2 on the jetson thor
linux·realsense2
BestOrNothing_20152 小时前
(3)Ubuntu 22.04 双系统安装全过程记录
linux·ubuntu22.04·双系统安装
寂柒3 小时前
Linux——基础IO
linux
杨云龙UP3 小时前
Oracle ASM磁盘组空间分配与冗余理解
linux·运维·数据库·sql·oracle
朽棘不雕4 小时前
Linux权限
linux
minji...4 小时前
Linux 库制作与原理(三)深入动静态链接原理
linux·运维·服务器·c++