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

相关推荐
天空'之城4 小时前
Linux 系统编程 12:TCP 进阶
linux·网络编程
bkspiderx4 小时前
rpath:Linux 中固定共享库搜索路径的“永久解决方案”
linux·rpath·固定共享库搜索路径
wbs_scy4 小时前
仿 muduo 高并发服务器项目:从 timerfd 到时间轮实现定时任务机制
linux·服务器·c++
AI的探索之旅4 小时前
从 Ubuntu 14.04 到 24.04:TI AM335x 开发环境完整迁移与 Agent 接管方案
linux·数据库·嵌入式硬件·ubuntu·postgresql
阿pin4 小时前
Android随笔-pipe是什么?
android·linux·pipe
小趴菜え4 小时前
升级Ubuntu20.04版本至Ubuntu22.04
linux·运维
辰三5 小时前
统信 UOS + GBase 8s 国产化环境部署实战:从虚拟机到数据库连接完整指南
linux·c#
Darkwanderor5 小时前
Linux进程优先级操作
linux·运维·c语言·c++
c_zyer6 小时前
一站式可观测新选择:OpenObserve 深度对标 ELK / Grafana+Prometheus / Netdata,附Docker一键部署实战
elk·grafana·prometheus·netdata·openobserve
AOwhisky6 小时前
Linux(CentOS)系统管理入门笔记(第一期)——从 Multics 到主流发行版
linux·运维·笔记·centos·云计算