怎么安装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

相关推荐
不知几秋3 小时前
数字取证-内存取证(volatility)
java·linux·前端
欧先生^_^7 小时前
Linux内核可配置的参数
linux·服务器·数据库
海尔辛7 小时前
学习黑客5 分钟读懂Linux Permissions 101
linux·学习·安全
王RuaRua8 小时前
[数据结构]5. 栈-Stack
linux·数据结构·数据库·链表
曼岛_8 小时前
[架构之美]linux常见故障问题解决方案(十九)
linux·运维·架构
tan180°8 小时前
Linux进程信号处理(26)
linux·c++·vscode·后端·信号处理
大神的风范8 小时前
从0开始学linux韦东山教程第三章问题小结(4)
linux·服务器
sz66cm9 小时前
Linux基础 -- SSH 流式烧录与压缩传输笔记
linux·笔记·ssh
YOYO--小天9 小时前
RS485和RS232 通信配置
linux·嵌入式硬件
Lw老王要学习9 小时前
Linux数据库篇、第一章_02_MySQL的使用增删改查
linux·运维·数据库·mysql·云计算·it