تخطَّ إلى المحتوى

Prometheus و Grafana و Loki و OpenTelemetry

ستفهم أدوار Prometheus و Grafana و Loki و OpenTelemetry، وكيف تربطها بمؤشرات Production مثل latency و error rate و saturation.

Observability تجيب عن: ماذا يحدث؟ لماذا يحدث؟ من تأثر؟ وهل نحتاج rollback؟

flowchart LR
App[Application] --> Metrics[Prometheus]
App --> Logs[Loki]
App --> Traces[OpenTelemetry Collector]
Metrics --> Grafana[Grafana]
Logs --> Grafana
Traces --> Grafana
Metrics --> Alertmanager[Alertmanager]
Terminal window
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
helm upgrade --install monitoring prometheus-community/kube-prometheus-stack \
--namespace monitoring --create-namespace
kubectl -n monitoring get pods

Expected output:

monitoring-grafana-... 3/3 Running
monitoring-kube-prometheus... 1/1 Running
monitoring-prometheus... 2/2 Running
المؤشرلماذا يهم؟
Request rateحجم traffic
Error rateنسبة الفشل
Duration p95/p99تجربة المستخدم
CPU/Memoryضغط الموارد
Restartsاستقرار Pods
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: web
labels:
release: monitoring
spec:
selector:
matchLabels:
app: web
endpoints:
- port: metrics
path: /metrics
interval: 30s

Lab: تشغيل monitoring stack محلي

المستوى: مبتدئ الوقت: 45 دقيقة الأدوات: helm, kubectl

الهدف: تثبيت kube-prometheus-stack وفحص Pods وفتح Grafana.

  • Helm مثبت.
  • Cluster محلي بموارد كافية.
Terminal window
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
helm upgrade --install monitoring prometheus-community/kube-prometheus-stack --namespace monitoring --create-namespace
kubectl -n monitoring get pods
kubectl -n monitoring port-forward svc/monitoring-grafana 3000:80
Forwarding from 127.0.0.1:3000 -> 3000
Terminal window
helm uninstall monitoring -n monitoring
kubectl delete namespace monitoring
الخطأالحل
alerts كثيرة بلا actionاجعل كل alert مرتبطا بإجراء واضح
logs فقط بدون metricsلن تعرف التأثير الكلي
metrics بلا labels جيدةصعب فصل services والبيئات