怎么安装Grafana-Loki

How to install Grafana-Loki to query logs from your k8s servers?

Requirements:

System: ubuntu

Helm3 (Assuming installed)

Grafana

Loki

Promtail (send data[logs] to Loki)

Step to install Grafana-loki

  1. Install Grafana on k8s:

Refer: https://grafana.com/docs/grafana/latest/setup-grafana/installation/kubernetes/

  1. Install data source -- Loki by helm3

Refer: https://grafana.com/docs/loki/latest/setup/install/helm/install-monolithic/

Notice:

After installed, You can get a gateway address of Loki, which is used by Promtail later

bash 复制代码
***********************************************************************
Sending logs to Loki
***********************************************************************

Loki has been configured with a gateway (nginx) to support reads and writes from a single component.

You can send logs from inside the cluster using the cluster DNS:

http://loki-gateway.default.svc.cluster.local/loki/api/v1/push
  1. Install Promtail by helm3

Refer: https://grafana.com/docs/loki/latest/send-data/promtail/installation/

Notice:

Put your Loki-Gateway address here, For Loki-Auth required, Add X-Scope-OrgId: foo [Important]

yaml 复制代码
# values.yaml
config:
# publish data to loki
  clients:
    - url: http://loki-gateway/loki/api/v1/push
      X-Scope-OrgId: foo

Finally, All Requirements are done.

Now you can use Grafana to see all logs you want, But set up Data sources first.

The Problems may appear && How to deal:

  1. Label amounts out of limit
bash 复制代码
# from Promtail you can get the error like below
error: loki has 16 label names; limit 15

Solution: Update your values of Promtail, Try official values for helm install Promtail

  1. HTTP 401
bash 复制代码
level=error ts=2024-09-05T07:53:52.821695784Z caller=client.go:430 component=client host=loki-gateway.default.svc.cluster.local msg="final error sending batch" status=401 tenant= error="server returned HTTP status 401 Unauthorized (401): no org id"

Solution: Add X-Scope-OrgId to values.yaml of Promtail

If this happening when you add data source by using Grafana, Also, add X-Scope-OrgId to Custom Header

相关推荐
likfishdn14 分钟前
Linux的文件与目录管理
linux·运维·服务器
chian-ocean33 分钟前
Linux 文件缓冲区:高效数据访问的幕后推手
linux·运维·服务器
加油=^_^=35 分钟前
【Linux】进程优先级 | 进程调度(三)
linux·运维·服务器
吃汤圆的抹香鲸1 小时前
GoLand 安装包 绿色版 Win,Mac,Linux 包含IntelliJ全家桶 专为Go语言设计的集成开发环境(IDE)
linux·windows·macos·go·intellij-idea·go1.19
追寻光1 小时前
Cannot find a valid baseurl for repo: base/7/x86_64
linux
元气满满的热码式1 小时前
Docker数据卷操作实战
linux·运维·docker·云原生·容器
陆沙1 小时前
deepseek-r1-centos-本地服务器配置方法
linux·服务器·centos
吃汤圆的抹香鲸2 小时前
Rider 安装包 绿色版 Win/Mac/Linux 适合.NET和游戏开发者使用 2025全栈开发终极指南:从零配置到企业级实战
linux·运维·windows·sql·游戏·macos·.net
sz66cm2 小时前
Linux基础 -- ARM 32 位架构动态注入代码技术文档
linux·arm开发·架构
Mr.pyZhang4 小时前
Android构建系统 - 04 编译产物
android·linux