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

相关推荐
2302_799525742 分钟前
【Linux】第十三章 访问Linux文件系统
linux·运维·服务器
磨叽的鱼5 分钟前
Ubuntu实现远程文件传输
linux·服务器·ubuntu
桦035 分钟前
Linux[配置vim]
linux·vim·excel
白总Server39 分钟前
智能座舱架构中芯片算力评估
linux·运维·服务器·开发语言·ai·架构·bash
Linux运维老纪2 小时前
Ansible 守护 Windows 安全(Ansible Safeguards Windows Security)
linux·windows·网络安全·自动化·云计算·运维开发·asible
bjzhang752 小时前
重启CentOS系统的rsyslogd服务
linux·centos·rsyslogd服务
Lw老王要学习2 小时前
Linux基础篇、第一章_01_3安装虚拟机手动安装部署Ubuntu22.04服务器
linux·运维·云计算
jsons12 小时前
Cliosoft安装
linux·运维·服务器
后院那片海2 小时前
Nginx核心功能
linux·服务器·nginx