怎么安装Grafana-Loki

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

Requirements:

System: ubuntu

Helm3 (Assuming installed)

Grafana

Loki

Promtail (send datalogs 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

相关推荐
听风3473 小时前
Arch Linux 软件安装完全指南
linux·运维·archlinux·pacman
网络安全零基础教程4 小时前
网络安全春招面试避坑与复盘指南
linux·网络·安全·web安全·面试·职场和发展
扛枪的书生4 小时前
TigerVNC 安装流程
linux
Mortalbreeze4 小时前
深入 Linux Socket 编程:端口号、网络字节序与 struct sockaddr 详解
linux·服务器·网络·c++
躺柒5 小时前
读半导体简史08大型机
linux·服务器·c语言·数据库·unix·ibm
井川廊咏5 小时前
【总集篇】Linux | 如何创建一个 home 目录在 /data 磁盘的 sudo 用户(补档)
linux·运维·服务器
Kina_C5 小时前
LVS负载均衡的十二种核心调度算法
linux·运维·算法·负载均衡·lvs
shencz20005 小时前
用bc脚本求解大质数
linux
AOwhisky5 小时前
Linux(CentOS)系统管理入门笔记(第十五期)——文件系统与存储管理(上篇):设备识别、挂载与文件查找
linux·运维·笔记·centos·文件系统
寒水馨6 小时前
Linux下载、安装 Bun v1.3.14(附安装包bun-linux-x64.zip)
linux·javascript·typescript·node.js·bun·运行时·包管理器