Loki简单收集k8s容器日志使用
为了方便安装使用helm安装helm pull loki/loki-stacktar xf loki-stack-2.1.2.tgzhelm install loki loki-stack/cat<<END> grangfan.yamlapiVersion: apps/v1kind: Deploymentmetadata:name: grafanalabels:app: graf
·
为了方便安装使用helm安装
helm repo add loki https://grafana.github.io/loki/charts && helm repo update
helm pull loki/loki-stack
tar xf loki-stack-2.1.2.tgz
helm install loki loki-stack/
cat<<END> grangfan.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: grafana
labels:
app: grafana
spec:
replicas: 1
selector:
matchLabels:
app: grafana
template:
metadata:
labels:
app: grafana
spec:
containers:
- name: grafana
image: grafana/grafana:latest
volumeMounts:
- name: timezone
mountPath: /etc/localtime
volumes:
- name: timezone
hostPath:
path: /usr/share/zoneinfo/Asia/Shanghai
---
apiVersion: v1
kind: Service
metadata:
name: grafana-svc
#namespace: test
spec:
ports:
- port: 3000
targetPort: 3000
nodePort: 3303
type: NodePort
selector:
app: grafana
END
登录granfan
使用pod标签方式匹配一个返回200的请求
多行查询
匹配多个关键字
如果不知道pods的标签可以直接使用以下快速翻页查找的方式
各种骚的查询
更多语法参加可见官网
https://grafana.com/docs/loki/latest/logql/
更多推荐
已为社区贡献82条内容
所有评论(0)