云原生日志神器之Loki
【摘要】 一 背景 1.1 需求 1.2 loki简介Loki 是一个受 Prometheus 启发的水平可伸缩的、高可用的、多租户的日志聚合系统。它的设计非常具有成本效益和易于操作。它不索引日志的内容,而是索引每个日志流的一组标签。 二 特点 2.1 Loki与其他系统对比不会对日志进行全文索引。通过存储压缩的、非结构化的日志,只索引元数据,Loki 操作更简单,运行成本也更低。索引和组日志流使用...
一 背景
1.1 需求
1.2 loki简介
Loki 是一个受 Prometheus 启发的水平可伸缩的、高可用的、多租户的日志聚合系统。它的设计非常具有成本效益和易于操作。它不索引日志的内容,而是索引每个日志流的一组标签。
二 特点
2.1 Loki与其他系统对比
- 不会对日志进行全文索引。通过存储压缩的、非结构化的日志,只索引元数据,Loki 操作更简单,运行成本也更低。
- 索引和组日志流使用与 Prometheus 相同的标签,使您能够使用与 Prometheus 相同的标签在度量和日志之间无缝切换。
- 是一个特别适合存储库伯尼特斯 Pod 原木。像 Pod 标签这样的元数据会被自动刮取并编入索引。
- 在 Grafana 得到了本地支持(需要 Grafana v6.0)。
2.2 loki的组建
-
Promtail 是一个代理人,负责收集日志并发送给Loki。
-
Loki 是主服务器,负责存储日志和处理查询。
-
Grafana用于查询和图形化展示日志。
2.3 原理
Loki 类似于 Prometheus,但是对于日志: 我们更喜欢使用基于多维标签的索引方法,并且希望使用单一二进制文件,操作起来很方便,没有依赖关系。洛基与普罗米修斯不同,他们更关注日志而不是度量,通过推送而不是拉送日志。
三 部署
3.1 安装Loki
3.1.1 利用helm安装loki
helm repo add loki https://grafana.github.io/loki/charts
helm repo update
# 通过存储类部署
[root@master ~]# helm upgrade --install loki --namespace=loki loki/loki-stack --set grafana.enabled=true,prometheus.enabled=true,prometheus.alertmanager.persistentVolume.enabled=false,prometheus.server.persistentVolume.enabled=false,loki.persistence.enabled=true,loki.persistence.storageClassName=rbd,loki.persistence.size=5Gi
Release "loki" does not exist. Installing it now.
NAME: loki
LAST DEPLOYED: Fri Dec 18 15:33:33 2020
NAMESPACE: loki
STATUS: DEPLOYED
RESOURCES:
==> v1/ClusterRole
NAME AGE
loki-grafana-clusterrole 2s
loki-prometheus-alertmanager 2s
loki-prometheus-pushgateway 2s
loki-prometheus-server 2s
loki-promtail-clusterrole 2s
==> v1/ClusterRoleBinding
NAME AGE
loki-grafana-clusterrolebinding 2s
loki-prometheus-alertmanager 2s
loki-prometheus-pushgateway 2s
loki-prometheus-server 2s
loki-promtail-clusterrolebinding 2s
==> v1/ConfigMap
NAME DATA AGE
loki-grafana 1 1s
loki-grafana-test 1 1s
loki-loki-stack 1 1s
loki-loki-stack-test 1 1s
loki-prometheus-alertmanager 1 1s
loki-prometheus-server 5 1s
loki-promtail 1 1s
==> v1/DaemonSet
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
loki-prometheus-node-exporter 4 4 0 4 0 <none> 1s
loki-promtail 4 4 0 4 0 <none> 1s
==> v1/Deployment
NAME READY UP-TO-DATE AVAILABLE AGE
loki-grafana 0/1 1 0 1s
loki-kube-state-metrics 0/1 1 0 1s
loki-prometheus-alertmanager 0/1 1 0 1s
loki-prometheus-pushgateway 0/1 1 0 1s
loki-prometheus-server 0/1 1 0 1s
==> v1/Pod(related)
NAME READY STATUS RESTARTS AGE
loki-0 0/1 Pending 0 2s
loki-0 0/1 Pending 0 2s
loki-0 0/1 Pending 0 2s
loki-0 0/1 Pending 0 2s
loki-0 0/1 Pending 0 2s
loki-0 0/1 Pending 0 2s
loki-0 0/1 Pending 0 2s
loki-0 0/1 Pending 0 2s
==> v1/Role
NAME AGE
loki 2s
loki-grafana-test 2s
loki-promtail 2s
==> v1/RoleBinding
NAME AGE
loki 2s
loki-grafana-test 2s
loki-promtail 2s
==> v1/Secret
NAME TYPE DATA AGE
loki Opaque 1 1s
loki-grafana Opaque 3 1s
==> v1/Service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
loki ClusterIP 10.233.35.11 <none> 3100/TCP 1s
loki-grafana ClusterIP 10.233.55.139 <none> 80/TCP 1s
loki-headless ClusterIP None <none> 3100/TCP 1s
loki-kube-state-metrics ClusterIP 10.233.17.40 <none> 8080/TCP 1s
loki-prometheus-alertmanager ClusterIP 10.233.26.110 <none> 80/TCP 1s
loki-prometheus-node-exporter ClusterIP None <none> 9100/TCP 1s
loki-prometheus-pushgateway ClusterIP 10.233.25.28 <none> 9091/TCP 1s
loki-prometheus-server ClusterIP 10.233.46.145 <none> 80/TCP 1s
==> v1/ServiceAccount
NAME SECRETS AGE
loki 1 1s
loki-grafana 1 1s
loki-grafana-test 1 1s
loki-kube-state-metrics 1 1s
loki-prometheus-alertmanager 1 1s
loki-prometheus-node-exporter 1 1s
loki-prometheus-pushgateway 1 1s
loki-prometheus-server 1 1s
loki-promtail 1 1s
==> v1/StatefulSet
NAME READY AGE
loki 0/1 1s
==> v1beta1/ClusterRole
NAME AGE
loki-kube-state-metrics 2s
==> v1beta1/ClusterRoleBinding
NAME AGE
loki-kube-state-metrics 2s
==> v1beta1/PodSecurityPolicy
NAME PRIV CAPS SELINUX RUNASUSER FSGROUP SUPGROUP READONLYROOTFS VOLUMES
loki false RunAsAny MustRunAsNonRoot MustRunAs MustRunAs true configMap,emptyDir,persistentVolumeClaim,secret,projected,downwardAPI
loki-grafana false RunAsAny RunAsAny RunAsAny RunAsAny false configMap,emptyDir,projected,secret,downwardAPI,persistentVolumeClaim
loki-grafana-test false RunAsAny RunAsAny RunAsAny RunAsAny false configMap,downwardAPI,emptyDir,projected,secret
loki-promtail false RunAsAny RunAsAny RunAsAny RunAsAny true secret,configMap,hostPath,projected,downwardAPI,emptyDir
==> v1beta1/Role
NAME AGE
loki-grafana 2s
==> v1beta1/RoleBinding
NAME AGE
loki-grafana 2s
NOTES:
The Loki stack has been deployed to your cluster. Loki can now be added as a datasource in Grafana.
See http://docs.grafana.org/features/datasources/loki/ for more detail.
参考链接
- https://github.com/grafana/loki
- https://grafana.com/docs/loki/latest/installation/
- https://grafana.com/docs/loki/latest/clients/promtail/configuration/
- https://mp.weixin.qq.com/s?__biz=MzU1OTgxMTg2Nw==&mid=2247496934&idx=1&sn=1c265116d0395e3176f2f939a9638d63&chksm=fc132892cb64a18448755f527a4f6fc9f35a7c01c19cfa9f1fdf205c05f995df87f5d34204b7&scene=132#wechat_redirect
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)