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

相关推荐
Winner130011 分钟前
Debian、Buildroot 和 Ubuntu 都是基于 Linux 的系统区别
linux·ubuntu·debian
1nullptr38 分钟前
UNIX程序设计基本概念和术语
linux
是阿建吖!1 小时前
【Linux | 网络】网络基础
linux·网络
mmoyula1 小时前
【RK3568 驱动开发:实现一个最基础的网络设备】
android·linux·驱动开发
阿杆1 小时前
😡同事查日志太慢,我现场教他一套 grep 组合拳!
linux·后端
墨小傲2 小时前
基于Linux下的vscode c/c++开发环境搭建详细教程
linux·c语言·vscode
cui_win2 小时前
【网络】Linux 内核优化实战 - net.ipv4.tcp_timestamps
linux·网络·tcp/ip
czhc11400756632 小时前
Linux 77 FTP
linux·运维·服务器
魂尾ac2 小时前
Centos Docker 安装(100%成功)
linux·docker·centos
天若有情6732 小时前
【Linux】02_CentOS 7 开机运行级别详解:从基础概念到实战配置
linux·运维·centos