前言
别问为什么使用loki,问就是喜欢grafana全家桶
Rancher Grafana 集成
写完了发现是监控,官网传送门
至于有啥不爽的可以在Rancher的应用-已安装的应用中修改,比如我就不爽这个继承grafana是9.x版本的,在10.x版本支持的中文。我就像换了。
如何修改查看应用Values YAML。
- 修改grafana的密码:
grafana.adminPassword
grafana:
adminPassword: xxxxxxxxx
- 修改grafana镜像:
global.image.repository
global:
image:
repository: grafana/grafana
- 修改grafana镜像版本:
global.image.tag
global:
image:
tag: 10.0.1
grafana-loki 集成
可以选择helm直接安装,也可以在Rancher中安装,下面介绍在Rancher中安装
- 首先需要在应用中Chart仓库中添加仓库。仓库地址:https://grafana.github.io/helm-charts
- 在应用–Chart中添加应用安装,在第一步建议勾上
在安装前自定义helm选项,以便后续调整超时时间。 - 配置Loki
我这里使用的是ceph的S3作为存储后端-
修改存储类型为S3:
loki.storage.type: s3# 这是默认选项 -
修改s3的配置: 在
loki.storage.s3中修改如下accessKeyId: xxxxxxx endpoint: https://xxx.xxx.xxx.cnxxx http_config: {} insecure: false region: us-east-1 s3: null s3ForcePathStyle: true secretAccessKey: xxxxxxx signatureVersion: v4按自己实际情况来
-
修改
auth_enabled为false这里把我坑到了,如果为
true,在grafana中添加数据源会报错Unable to connect with Loki (no org id )
然后根据提示Google到stackoverflow上的一个问题Configuring Loki Datasource for Grafana - Error no Org id found
在这个问题的唯一一个answer中找到了官网Authentication说明
在Grafana中添加数据源的时候在Custom HTTP Headers选项中添加上X-Scope-OrgID试了试,又出现了新问题:“Data source connected, but no labels received. Verify that Loki and Promtail is configured properly.。并且Promtail也爆出grafana loki erver returned HTTP status 401 Unauthorized (401): no org id。
最后在GitHub上Loki的issues中找到了答案:传送门 -
如果需要外部向Loki中push日志还需要配置ingress:
gateway.ingress.enabled
-
- 创建
output和Flows,详情见官网:传送门-自定义资源配置需要注意的是目标URL是Loki的
gateway的DNS加上/loki/api/v1/push:如http://loki-gateway.cattle-monitoring-system/loki/api/v1/push
还有flow的匹配规则需要自行定义
本文介绍了如何在Rancher中集成Grafana和Loki进行日志管理。首先,文章提到喜欢使用Grafana全家桶,并详细说明了如何在Rancher中修改Grafana的版本和密码。接着,重点讲述了在Rancher中通过Helm图表安装Loki的过程,包括添加仓库、配置S3存储后端以及解决配置过程中遇到的问题。最后,提到了为了将外部日志推送到Loki,需要配置ingress和Flow匹配规则。
1327

被折叠的 条评论
为什么被折叠?



