<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>loki on 空树之空</title><link>https://yezihack.github.io/tags/loki/</link><description>Recent content in loki on 空树之空</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Wed, 14 Oct 2026 17:51:52 +0800</lastBuildDate><atom:link href="https://yezihack.github.io/tags/loki/index.xml" rel="self" type="application/rss+xml"/><item><title>Grafana Loki 完全指南：架构、组件、安装与 Kubernetes 实践</title><link>https://yezihack.github.io/grafana-loki-complete-guide/</link><pubDate>Wed, 14 Oct 2026 17:51:52 +0800</pubDate><guid>https://yezihack.github.io/grafana-loki-complete-guide/</guid><description>版本说明：Loki 3.x 迭代较快，尤其是 Helm Chart 的部署模式和实验性组件（如 Bloom）。本文以 3.x 为准，落地前请对照官方文档核对 values 字段。
采集器说明：Promtail 已进入 EOL，官方推荐迁移到 Grafana Alloy，本文采集端统一使用 Alloy。
一、Loki 是什么 Loki 是 Grafana Labs 开源的水平可扩展、多租户的日志聚合系统，口号是 &amp;ldquo;Like Prometheus, but for logs&amp;rdquo;。
和 Elasticsearch 的核心区别：
Loki Elasticsearch 索引内容 只索引标签（元数据） 对日志全文建倒排索引 存储成本 低（压缩块存对象存储） 高（索引体积常与原文相当） 查询方式 标签筛选 + 分布式 grep（LogQL） 全文检索 DSL 运维复杂度 较低 较高 适合场景 运维排障、应用日志、与 Metrics/Trace 联动 复杂全文检索、日志分析 因此 Loki 的使用关键在于：标签设计要克制，正文靠 LogQL 过滤。
二、整体架构与数据流 应用日志 → 采集器（Alloy / Promtail / Fluent Bit …） │ HTTP push ▼ ┌─ Distributor ─┐ 写路径 │ （校验/分片） │ └──────┬────────┘ ▼ 一致性哈希环 + 副本 Ingester ×N （内存 + WAL → 压缩成 chunk） │ flush ▼ 对象存储（chunks） + TSDB 索引 Grafana ──► Query Frontend ──► Query Scheduler ──► Querier ×N 读路径 （拆分/缓存） （队列） ├─ 查 Ingester（近期数据） └─ 查对象存储（历史数据，经 Index Gateway） 写路径：采集器推送 → Distributor 校验并按 stream 哈希 → 写入多个 Ingester（默认 3 副本）→ Ingester 在内存中攒 chunk 并写 WAL → 满足大小/时间条件后刷到对象存储。</description></item></channel></rss>