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

相关推荐
cui_ruicheng44 分钟前
Linux进程间通信(三):System V IPC与共享内存
linux·运维·服务器
蚰蜒螟1 小时前
深入 Linux 内核同步机制:从 futex 到 spinlock 的完整旅程
linux·windows·microsoft
运维全栈笔记1 小时前
Linux安装配置Tomcat保姆级教程:从部署到性能调优
linux·服务器·中间件·tomcat·apache·web
dllmayday2 小时前
Linux 上用终端连接 WiFi
linux·服务器·windows
峥无3 小时前
Linux系统编程基石:静态库·动态库·ELF文件·进程地址空间全景图
linux·运维·服务器
用户2367829801684 小时前
从 chmod 755 说起:Unix 文件权限到底是怎么算的?
linux
Strugglingler4 小时前
【systemctl 学习总结】
linux·systemd·systemctl·journalctl·unit file
嵌入式×边缘AI:打怪升级日志5 小时前
100ASK-T113 Pro 开发板 Bootloader 完全开发指南
linux·ubuntu·bootloader
charlie1145141916 小时前
Linux 字符设备驱动:cdev、设备号与设备模型
linux·开发语言·驱动开发·c
handler016 小时前
Linux 内核剖析:进程优先级、上下文切换与 O(1) 调度算法
linux·运维·c语言·开发语言·c++·笔记·算法