المختبر 11.1 - تثبيت Prometheus وGrafana
أهداف المختبر
في نهاية هذا المختبر، ستكون قادرًا على:
- تثبيت Prometheus في Kubernetes.
- تثبيت Grafana في Kubernetes.
- تكوين Prometheus لجمع المقاييس.
- الوصول إلى لوحات التحكم في Grafana.
- فهم تكامل Prometheus-Grafana.
المدة المقدرة
60-75 دقيقة
المتطلبات الأساسية
- تم تثبيت وتكوين kubectl.
- عنقود Kubernetes محلية وظيفية.
- تم تثبيت Helm (لتسهيل التثبيت).
الجزء 1: تثبيت Prometheus باستخدام Helm
الخطوة 1.1: إضافة مستودع Prometheus
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
الخطوة 1.2: تثبيت Prometheus
helm install prometheus prometheus-community/kube-prometheus-stack \
--namespace monitoring \
--create-namespace
انتظر حتى تكون الـ Pods جاهزة:
kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=prometheus -n monitoring --timeout=300s
الجزء 2: التحقق من التثبيت
الخطوة 2.1: التحقق من الـ Pods
kubectl get pods -n monitoring
يجب أن ترى:
- prometheus-operator
- prometheus-kube-prometheus-prometheus
- grafana
- kube-state-metrics
- node-exporter
الخطوة 2.2: التحقق من الخدمات
kubectl get svc -n monitoring
الجزء 3: الوصول إلى Prometheus
الخطوة 3.1: توجيه المنفذ إلى Prometheus
kubectl port-forward -n monitoring svc/prometheus-kube-prometheus-prometheus 9090:9090
قم بالوصول إلى http://localhost:9090 في متصفحك.
الخطوة 3.2: اختبار استعلامات PromQL
في واجهة Prometheus، اختبر:
up
container_memory_usage_bytes
kube_pod_info
الجزء 4: الوصول إلى Grafana
الخطوة 4.1: الحصول على كلمة المرور
kubectl get secret --namespace monitoring prometheus-grafana -o jsonpath="{.data.admin-password}" | base64 --decode
اسم المستخدم الافتراضي هو admin.
الخطوة 4.2: توجيه المنفذ إلى Grafana
kubectl port-forward -n monitoring svc/prometheus-grafana 3000:80
قم بالوصول إلى http://localhost:3000 وقم بتسجيل الدخول.
الجزء 5: استكشاف لوحات التحكم
الخطوة 5.1: لوحات التحكم المسبقة التكوين
يأتي Grafana مع لوحات تحكم مسبقة التكوين:
- Kubernetes / Compute Resources / Cluster
- Kubernetes / Compute Resources / Namespace
- Kubernetes / Compute Resources / Pod
استكشف هذه اللوحات.
الجزء 6: التنظيف
helm uninstall prometheus -n monitoring
kubectl delete namespace monitoring
ملخص المختبر
في هذا المختبر، قمت بتثبيت Prometheus وGrafana في Kubernetes. تعلمت كيفية الوصول إلى الواجهات، واستخدام PromQL، واستكشاف لوحات التحكم في Grafana.
الخطوات التالية
سيعرض لك المختبر التالي كيفية إنشاء لوحات تحكم مخصصة في Grafana.
المختبر 11.2: إنشاء لوحات تحكم مخصصة
تم إنشاء المختبر في: ديسمبر 2024