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

相关推荐
Linux技术芯8 小时前
浅谈nvme驱动中的nvme_alloc_ns函数的实现原理和底层逻辑
linux
AOwhisky9 小时前
Linux防火墙管理指南
linux·运维·服务器
礼拜天没时间.9 小时前
Linux 系统规范配置:建立标准目录结构、 repo 源获取、修改终端变色
linux·服务器·centos·repo·终端变色
liqb3659 小时前
RUN_TO_PARITY特性对调度延时的影响
linux
Ephemeral Memories9 小时前
ubuntu安装软件失败以及运行闪退
linux·ubuntu
网安CILLE9 小时前
PHP四大输出语句
linux·开发语言·python·web安全·网络安全·系统安全·php
ghostmen9 小时前
openEuler 安装 K3S
linux·k3s
RisunJan9 小时前
Linux命令-iptables(配置防火墙规则的核心工具)
linux·运维·服务器
KL's pig/猪头/爱心/猪头10 小时前
写一个rv1106的led驱动1-整体架构
linux·驱动开发
叁金Coder10 小时前
【CentOS-Stream-9 配置网卡信息】
linux·运维·centos