kubernetes-event-exporter+loki+grafana实现对k8s event监控管理
2.修改配置指定kubeconfig3.修改config.yaml配置loki sink。
·
部署 kubernetes-event-exporter
1.Installing the Chart
#helm install kubernetes-event-exporter oci://registry-1.docker.io/bitnamicharts/kubernetes-event-exporter
2.修改config.yaml配置loki sink
leaderElection: {}
logFormat: json
logLevel: debug
receivers:
- loki:
url: http://10.35.112.161:3100/loki/api/v1/push
streamLabels:
container: event-exporter-k8s2-edge
name: loki
- file:
path: /data/logs/kubernetes-event/event.log
name: file
route:
routes:
- match:
- receiver: loki
- match:
- receiver: file
应用配置
$ kubectl -n kube-system create cm kubernetes-event-exporter --from-file=config.yaml=kubernetes-event-exporter.cm --dry-run=client -o yaml|kubectl replace -f -
部署loki
1.get repo
#helm repo add grafana https://grafana.github.io/helm-charts
#helm pull grafana/loki-stack --untar --version 2.6.4
2.配置
#cd loki-stack
#vim values-prod.yaml
# values-prod.yaml
loki:
enabled: true
replicas: 1
rbac:
pspEnabled: false
persistence:
enabled: true
storageClassName: local-path
size: 2Gi
promtail:
enabled: false
rbac:
pspEnabled: false
3.配置pv
- 配置sc
#vim local-storageclass.yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: local-path
provisioner: kubernetes.io/no-provisioner
reclaimPolicy: Retain
volumeBindingMode: WaitForFirstConsumer
- 制备pv
#vim pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: loki-pv
spec:
capacity:
storage: 2Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: local-path
local:
path: /data/loki
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: loki
operator: In
values:
- enable
loki配置禁用并发请求
- kubectl get secret/loki -o yaml 将配置后解码后添加parallelise_shardable_queries: false,再编码提交
...
limits_config:
enforce_metric_name: false
reject_old_samples: true
reject_old_samples_max_age: 168h
query_range:
parallelise_shardable_queries: false
...
提交部署loki
#helm upgrade --install loki -f values-prod.yaml .
curl测试
#curl -H "Content-Type: application/json" -s -X POST "http://10.x.x.x:3100/loki/api/v1/push" --data-raw '{"streams": [{ "stream": { "foo": "bar2" }, "values": [ [ "1726281321000000000", "fizzbuzz" ] ] }]}'
更多推荐
已为社区贡献1条内容
所有评论(0)