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

相关推荐
炫酷的伊莉娜37 分钟前
【Linux cmd】查看 CPU 使用率的几个命令
linux
rosemary5121 小时前
Ubuntu 20.04 postgresql
linux·ubuntu·postgresql
视觉AI2 小时前
Jetson系统烧录与环境配置全流程详解(含驱动、GCC、.Net设置)
linux·人工智能·ubuntu·计算机视觉·.net
wb1893 小时前
Linux火墙管理及优化
linux·运维·笔记·云计算
NEXU53 小时前
Linux:库与链接
linux
Themberfue3 小时前
RabbitMQ ⑥-集群 || Raft || 仲裁队列
linux·运维·分布式·后端·rabbitmq·ruby
三三十二3 小时前
什么是Linux
linux·运维·服务器
ascarl20105 小时前
在 “Linux 9“ 系统快速安装配置RabbitMQ
linux·rabbitmq·ruby
叫我黎大侠5 小时前
使用 LibreOffice 实现各种文档格式转换(支持任何开发语言调用 和 Linux + Windows 环境)[全网首发,保姆级教程,建议收藏]
java·大数据·linux·开发语言·python·c#·php
不愧是你呀6 小时前
深度剖析并发I/O模型select、poll、epoll与IOCP核心机制
linux·服务器·网络·windows