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

相关推荐
huangyuchi.10 分钟前
【Linux网络】UDP协议详解:透过源码看透“面向数据报”与“缓冲区”的本质
linux·网络·udp·报文·linux网络·传输层协议·报头
林九生10 分钟前
【Centos7】CentOS 7 yum源失效解决方案:Could not resolve host mirrorlist.centos.org
linux·运维·centos
福尔摩斯张13 分钟前
【实战】C/C++ 实现 PC 热点(手动开启)+ 手机 UDP 自动发现 + TCP 通信全流程(超详细)
linux·c语言·c++·tcp/ip·算法·智能手机·udp
了一梨16 分钟前
网络编程:UDP Socket
linux·网络协议·udp
ChristXlx24 分钟前
Linux安装MongoDB(虚拟机适用)
linux·mongodb·postgresql
AttaGain24 分钟前
禁用Ubuntu24.04休眠模式
linux
kaka_199425 分钟前
如何解决驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。
linux·安全·ssl
我是谁??28 分钟前
windows11的ubuntu子系统如何识别到U盘
linux·运维·ubuntu
qq_4557608529 分钟前
docker - 虚拟化和容器化
linux·运维·服务器
小年糕是糕手29 分钟前
【C++】string类(一)
linux·开发语言·数据结构·c++·算法·leetcode·改行学it