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.日志查询

相关推荐
小此方1 小时前
Re:Linux系统篇(五十七)线程篇 · 十:基于环形缓冲的生产者消费者模型与信号量
linux·运维·驱动开发
fanged1 小时前
Linux的DD命令
linux·运维·服务器
张洛闻Eren3 小时前
MySQL 管理复制拓扑【MySQL第四课】
linux·运维·数据库·mysql
xiaohua10093 小时前
Linux-JVM线程查询
linux·jvm
blueSatchel4 小时前
u-boot启动过程(bootROM到SPL到u-boot)
linux·u-boot
祖力554 小时前
快速学会数据结构中的链式队列与循环队列
linux·c语言·数据结构·算法
原凉是这样的丶4 小时前
Qwen3.8-27B 开源后,我用双 RTX 4090 跑通了:vLLM 0.27.1、128K 上下文与 MTP 实测
linux·算法
没伞的行者5 小时前
《C++ Primer Plus(第六版)全书代码整理 | 章节源码 + README知识总结(Gitee、GitHub开源)》
linux·开发语言·c++·gitee·github
北京迅为5 小时前
【迅为开发板专属工具】把烧写入口放进浏览器|Topeet RK Flash
linux·人工智能·嵌入式·rk3568·烧写