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

相关推荐
GeW1 小时前
从代码到共识:技术突围如何映照大国相处之道
linux
承渊政道2 小时前
Linux系统学习【进程信号详细解析——认识、产生、保存以及捕捉信号】
linux·学习·ubuntu·ssh·vs code·进程信号
硅基手札2 小时前
【linux内核专栏01】Linux 内核心智模型与设计哲学
linux·运维·驱动开发·开源软件
码完就睡2 小时前
Linux——socket网络编程
linux·运维·网络
道尔柯南2 小时前
【Linux】网络基础概念
linux·运维·网络
傲世仙尊3 小时前
从抢票事故到锁的原理-互斥条件变量与生产消费模型
linux·驱动开发
AI+程序员在路上3 小时前
AP6275S蓝牙双接口解析:HCI UART与PCM的分工与协同
linux·c语言·物联网
小此方3 小时前
Linux网络(十八):TCP连接管理详解:从三次握手、四次挥手到CLOSE_WAIT与TIME_WAIT,深入理解2MSL与端口复用
linux·网络·网络协议·tcp/ip
进击的荆棘3 小时前
Linux系统——文件(上)
linux·运维·服务器·文件
k4m7v2pz3 小时前
ThinkPad E490 风扇 “转两秒就停“ 实录:迟滞曲线 + 最短运转时间
linux·脚本·archlinux·thinkpad·风扇·散热