Skip to content

Latest commit

 

History

History
81 lines (62 loc) · 1.77 KB

observability.md

File metadata and controls

81 lines (62 loc) · 1.77 KB

可观测性

1. 日志

日志适配

  1. docker: 容器日志与日志 label 均从目录/var/lib/docker/containers/<container-id>/xxx 获取

  2. container: 改为日志从/var/log/containers 获取,日志 label 从 kube-apiserver 获取

2. 监控

前提是部署好 prometheus 和 grafana

1. 部署 kata-monitor

kubectl apply -f https://raw.githubusercontent.com/kata-containers/kata-containers/main/docs/how-to/data/kata-monitor-daemonset.yml

prometheus 添加抓取规则

spec:
  additionalScrapeConfigs:
  - job_name: 'kata'
    static_configs:
    - targets: ['localhost:8090']

通过 servicemonitor 的方式

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: kata-monitor
  namespace: kata-system
spec:
  endpoints:
  - interval: 15s
    path: /metrics
    port: metrics
  namespaceSelector:
    any: true
  selector:
    matchLabels:
      app: kata-monitor
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: kata-monitor
  name: kata-monitor
  namespace: kata-system
spec:
  ports:
    - name: metrics
      port: 8090
      protocol: TCP
      targetPort: 8090
  selector:
    app.kubernetes.io/name: kata-monitor
  type: ClusterIP

2. 配置 Grafana dashboard 面板

导入 https://raw.githubusercontent.com/kata-containers/kata-containers/main/docs/how-to/data/dashboard.json dashboard

kata 支持的 指标

https://github.com/kata-containers/kata-containers/blob/main/docs/design/kata-2-0-metrics.md

  1. Kata 2.0 Metrics Design
  2. monitor Kata Containers in Kubernetes