شعار K8s Loki Troubleshooting

K8s Loki Troubleshooting

مؤسسة
k8s-servant
k8s-loki-troubleshooting

استخدم هذه المهارة عندما يرفض Grafana Loki على Kubernetes السجلات أو يسقطها أو يعجز عن الاستعلام عنها: تتلقى التطبيقات العميلة رموز الحالة 400 أو 401 أو 429 من /loki/api/v1/push، أو تظهر رسائل "write operation failed" أو "has timestamp too old" أو "entry too far behind" أو "Per stream rate limit exceeded" أو "ingestion rate limit exceeded" أو "maximum active stream limit exceeded" أو "no org id" (غياب المستأجر X-Scope-OrgID)، أو يتعطل Loki عند بدء التشغيل مع "validating config" أو "invalid schema config"، أو تظهر "failed to flush chunks"، أو أخطاء ring أو memberlist ("empty ring"، "too many unhealthy instances in the ring")، أو تفشل الاستعلامات برسالة "the query time range exceeds the limit" أو تنتهي مهلتها. تفحص المشكلة باستخدام kubectl get والسجلات ونقاط Loki للقراءة فقط، وتقترح حلولًا. تبدأ بالقراءة وتطلب إذنك قبل إجراء أي تغيير.

نظرة عامة

الناشرk8s-servant
المستودعk8s-skills
اسم المهارةk8s-loki-troubleshooting
النجوم
36
التفريعات
7
الملفات المرفقة
2
الترخيصApache-2.0
الروابط
  • تعليمات بصيغة Markdown

    ملف SKILL.md يُحمّله النموذج عند الحاجة، فلا يستهلك توكنات إلا عندما يَرِد طلب ذو صلة فعلًا.

  • تعمل مع أي نموذج لغوي كبير

    مهارات الذكاء الاصطناعي مكتوبة بصيغة Markdown وليست شيفرة خاصة بمزوّد معيّن، لذا تعمل مع GPT أو Claude أو Gemini أو Grok أو نموذج محلي.

  • الملفات المرفقة: 2

    نصوص برمجية وقوالب ومراجع يمكن للنموذج قراءتها أثناء عمله. الملفات للقراءة فقط ولا تُنفّذ أبدًا.

  • مفتوحة المصدر

    نشرها k8s-servant على GitHub. اطّلع على المصدر قبل تثبيتها.

التثبيت

ثبّت مهارة الذكاء الاصطناعي K8s Loki Troubleshooting في TypingMind لاستخدامها مع أي نموذج لغوي كبير، أو أضفها إلى وكيل ذكاء اصطناعي آخر يقرأ SKILL.md.

1

التثبيت في TypingMind

يُثبّت TypingMind المهارة مباشرةً من مجلدها على GitHub — فيقرأ SKILL.md، ويجمع ملفات الموارد في حزمة، ويحفظ النتيجة محليًا.

  1. افتح التطبيق وانتقل إلى «الإضافات» ثم «المهارات».
  2. اختر «تثبيت من GitHub».
  3. الصق رابط مجلد المهارة الموضّح أدناه وأكّد التثبيت.
    https://github.com/k8s-servant/k8s-skills/tree/main/skills/k8s-loki-troubleshooting
  4. فعّل المهارة في كل محادثة تريد إتاحتها فيها.
الإضافات ← المهارات ← إضافة مهارة ← من رابط GitHub، ثم الصق رابط المجلد واضغط على «متابعة».
2

التثبيت في وكيل ذكاء اصطناعي آخر

يمكن لأي وكيل ذكاء اصطناعي يقرأ تنسيق Agent Skills استخدام هذه المهارة — انسخ المجلد إلى مجلد المهارات الخاص بذلك الوكيل.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/k8s-servant/k8s-skills.git /tmp/k8s-skills
mkdir -p .claude/skills
cp -r /tmp/k8s-skills/skills/k8s-loki-troubleshooting .claude/skills/k8s-loki-troubleshooting
أعد تشغيل Claude Code بعد النسخ ليتعرّف على المهارة الجديدة.

استخدمها في TypingMind

فعّل K8s Loki Troubleshooting في أي محادثة على TypingMind وسيتولى النموذج الباقي. تتضمن مطالبة النظام اسمها ووصفها، وبمجرد ورود طلب ذي صلة، يُحمّل النموذج التعليمات الكاملة تلقائيًا — فلا تحتاج إلى استدعائها يدويًا، ولا تستهلك أي توكنات حتى تُستخدم فعليًا.

يُحمّل النموذج مهارة K8s Loki Troubleshooting تلقائيًا بمجرد ورود طلب ذي صلة بها.

تعمل مع أي نموذج ذكاء اصطناعي

مهارات الذكاء الاصطناعي هي تعليمات بصيغة Markdown وليست شيفرة خاصة بمزوّد معيّن، لذا لا ترتبط K8s Loki Troubleshooting بالنموذج الذي كُتبت له. ثبّتها مرة واحدة في TypingMind واستخدمها مع GPT-5 أو Claude أو Gemini أو Grok أو DeepSeek أو Mistral أو Llama أو نموذج محلي تشغّله بنفسك — كل ذلك باستخدام مفاتيح API الخاصة بك.

  • تُحمَّل عند الحاجة فقط

    تتضمن مطالبة النظام الاسم والوصف فقط. وتُجلب التعليمات عند أول طلب ذي صلة، لذا لا تستهلك تعليمات المهارة أي توكنات ما دامت المهارة غير مستخدمة.

  • بدّل النماذج أثناء المحادثة

    لأن المهارة تعليمات وليست شيفرة، فإن تغيير النموذج لا يعطّلها — فالنموذج التالي يقرأ ملف SKILL.md نفسه.

تعليمات المهارة

هذا هو محتوى SKILL.md الذي يُحمّله النموذج. اقرأه قبل التثبيت — فالمهارة عبارة عن تعليمات سيتبعها نموذجك.

Loki troubleshooting

Find out why Loki does not accept, keep or return logs, and propose a fix. Read first, ask before changing. Run the investigation commands freely. Run a command under an "Ask first" line only after the user approves that exact command; if your credentials do not allow it, give it to the user to run. Never run a "Proposed fix"; hand it to the user.

Clients (Promtail, Grafana Alloy, Fluent Bit, the OpenTelemetry Collector) push log lines to /loki/api/v1/push. The distributor validates each line (labels, size, age) and applies the tenant's ingestion rate; the ingester applies per-stream limits and writes chunks to storage; queriers answer LogQL queries. In monolithic mode one pod (-target=all) runs every part; in microservices mode each part is its own workload. Loki answers a refused push with 400 (invalid, not retried), 429 (rate limit, retried) or 401 (no tenant), and logs refused pushes as msg="write operation failed" details="<reason>", except 401s, which it does not log.

The commands use placeholders: my-namespace, my-loki (the Loki workload, its Service and its ConfigMap) and my-app-logger (a client). Replace them with the real names. Never read Secrets. Loki's config may hold storage keys: if it is in a Secret, do not read it; if it is in a ConfigMap, read only the parts you need and never repeat a key, password or token you see. Prefer the /config endpoint, which masks typed secret fields. Avoid kubectl describe pod on Loki: it prints literal environment values.

Never call /flush or /ingester/shutdown, not even with GET: Loki flushes all chunks or shuts the ingester down. Never POST to a ring page (forget= removes an instance). Use only the read endpoints listed here.

When to use

  • A log agent reports 4xx errors from Loki, or logs are missing in Grafana.
  • Loki pods crash, restart, or are not Ready.
  • Queries fail, time out, or return nothing for data that was sent.

Hand-offs, by skill name. When the evidence points elsewhere, continue with that skill; if it is not installed, keep going with the steps here and tell the user which skill would help:

  • The client cannot reach Loki at all (DNS, Service, NetworkPolicy): k8s-network-troubleshooting.
  • The log agent itself fails (Fluent Bit, the OpenTelemetry Collector): k8s-fluent-bit-troubleshooting, k8s-opentelemetry-collector-troubleshooting.
  • Grafana's Loki datasource fails while Loki answers: k8s-grafana-troubleshooting.
  • Loki pods are Pending or OOMKilled: k8s-workload-troubleshooting; a full volume: k8s-storage-troubleshooting.

Investigate

Work through the steps in order. Stop when you have the cause and its evidence.

1. See Loki's pods and the client's result. The HTTP status the client got points to the part that refused it.

bash
kubectl get pods -n my-namespace -o wide
kubectl logs -n my-namespace deployment/my-app-logger --tail=20

2. Read Loki's log: refused pushes, start-up errors, storage and ring errors.

bash
kubectl logs -n my-namespace deployment/my-loki --tail=200 | grep -E 'level=(error|warn)'
kubectl logs -n my-namespace deployment/my-loki --previous --tail=50
kubectl get events -n my-namespace --sort-by=.lastTimestamp

3. Check where the config lives and what it sets: auth_enabled, the limits and the schema. Check the kind of object first; a Secret is not read. Match only the keys you need, so storage credentials near them are not printed.

bash
kubectl get deployment my-loki -n my-namespace -o jsonpath='{.spec.template.spec.containers[0].args}{"\n"}{range .spec.template.spec.volumes[*]}{.name}{" "}{.configMap.name}{.secret.secretName}{"\n"}{end}'
kubectl get configmap my-loki -n my-namespace -o jsonpath='{.data.config\.yaml}' | grep -E 'auth_enabled|store:|schema:|period:|reject_old_samples|ingestion_rate|ingestion_burst|per_stream_rate|max_global_streams|max_line_size'

4. Ask Loki itself, through the API server's service proxy, if your credentials allow get on services/proxy (the built-in view role does not). With auth_enabled: true the query endpoints need a tenant header and answer no org id here; the status endpoints below do not.

bash
kubectl get --raw /api/v1/namespaces/my-namespace/services/my-loki:http-metrics/proxy/ready
kubectl get --raw /api/v1/namespaces/my-namespace/services/my-loki:http-metrics/proxy/services
kubectl get --raw "/api/v1/namespaces/my-namespace/services/my-loki:http-metrics/proxy/config?mode=diff"
kubectl get --raw /api/v1/namespaces/my-namespace/services/my-loki:http-metrics/proxy/metrics | grep -E 'loki_discarded_samples_total|status_code="(4|5)'

5. Open the matching reference and follow its steps:

What you seeReference
Pushes refused (400, 401, 429), write operation failed, tenants, limitsreferences/ingestion.md
Loki does not start, not Ready, ring and memberlist, storage, flushes, retention, queriesreferences/startup-storage-queries.md

Read the results

What the common findings mean (Loki 3.7):

  • Client 400 and msg="write operation failed" details="entry for stream '{app=\"my-app\", service_name=\"my-app\"}' has timestamp too old: 2020-09-13T12:26:40Z, oldest acceptable timestamp is: ...": the lines are older than reject_old_samples_max_age (7 days by default). Loki adds the service_name label itself. The client's clock or its timestamps are wrong, or it replays old logs.
  • Client 401 and nothing in Loki's log: auth_enabled: true (multi-tenant) and the client sends no X-Scope-OrgID header; Loki answers no org id. Every client and the Grafana datasource need the tenant ID.
  • Client 429 with Per stream rate limit exceeded or ingestion rate limit exceeded for user ...: a stream or the tenant sends more than per_stream_rate_limit (3MB/s) or ingestion_rate_mb (4MB/s) allow. Clients retry 429s, so logs arrive late or not at all.
  • Loki in CrashLoopBackOff with msg="validating config" err="CONFIG ERROR: invalid schema config: validating period_config: tsdb must always have periodic config for index set to 24h": the tsdb index needs period: 24h. Clients then get connection refused or no endpoints.
  • failed to flush chunks: ...: the ingester cannot write to object storage; the wrapped error names the bucket, credentials or network problem. Data stays in memory and the WAL until it can.
  • too many unhealthy instances in the ring or empty ring: ingesters are not ACTIVE or not found (memberlist cannot join, pods not Ready).

State the cause in one sentence, then the evidence you saw (the client's status, Loki's log line, the config field), then the proposed fix.

Proposed fix

Show each fix to the user before running it: what it changes and how to undo it. Loki's config, its limits and its storage are shared by every client and tenant: never change them yourself; hand them to the user as proposed fixes. A client's own config (its timestamps, its tenant header, its URL) belongs to that client's owners. Prefer fixing the source (the Helm values, the manifests in Git). Write each undo with the values you found.

Change Loki's config in its source and roll it out, for example index.period: 24h, or limits_config.reject_old_samples_max_age for a client that must replay older logs:

Proposed fix: review before running. The agent does not run this.

bash
kubectl apply -f my-loki-config.yaml
kubectl rollout restart deployment/my-loki -n my-namespace
# Undo: kubectl apply -f my-loki-config-before.yaml, then restart my-loki again

After a client's fix rolls out, restart the client to retry at once:

Ask first: the agent runs this only after the user approves it.

bash
kubectl rollout restart deployment/my-app-logger -n my-namespace
# Undo: none needed; the restart only recreates the pods with the same template

Sources

Checked against the Loki 3.7 documentation and source (v3.7.9):

الملفات المرفقة

يقرأ النموذج هذه الملفات عند الحاجة ما دامت المهارة محمّلة. وهي متاحة للقراءة ولا تُنفّذ أبدًا.

الأسئلة الشائعة

ماذا تفعل مهارة الذكاء الاصطناعي K8s Loki Troubleshooting؟

استخدم هذه المهارة عندما يرفض Grafana Loki على Kubernetes السجلات أو يسقطها أو يعجز عن الاستعلام عنها: تتلقى التطبيقات العميلة رموز الحالة 400 أو 401 أو 429 من /loki/api/v1/push، أو تظهر رسائل "write operation failed" أو "has timestamp too old" أو "entry too far behind" أو "Per stream rate limit exceeded" أو "ingestion rate limit exceeded" أو "maximum active stream limit exceeded" أو "no org id" (غياب المستأجر X-Scope-OrgID)، أو يتعطل Loki عند بدء التشغيل مع "validating config" أو "invalid schema config"، أو تظهر "failed to flush chunks"، أو أخطاء ring أو memberlist ("empty ring"، "too many...

لماذا تستخدم K8s Loki Troubleshooting على TypingMind؟

لأنك تثبّتها مرة واحدة وتستخدمها مع أي نموذج. مهارة K8s Loki Troubleshooting عبارة عن نص Markdown وليست شيفرة خاصة بمزود بعينه، لذا تعمل المهارة نفسها مع GPT-5 أو Claude أو Gemini أو Grok أو نموذج محلي، ويمكنك تبديل النموذج أثناء المحادثة دون تعطّل المهارة. يعمل TypingMind بمفاتيح API الخاصة بك، فتدفع للمزودين مباشرةً بدلًا من اشتراك لكل مقعد، وتبقى مهاراتك ومحادثاتك في مساحة التخزين الخاصة بك.

كيف أثبّت K8s Loki Troubleshooting في TypingMind؟

في TypingMind، افتح «الإضافات»، ثم «المهارات»، ثم اختر «التثبيت من GitHub» والصق https://github.com/k8s-servant/k8s-skills/tree/main/skills/k8s-loki-troubleshooting. يقرأ TypingMind ملف SKILL.md الخاص بالمهارة، ويجمع ملفاتها ويثبّتها كمهارة يمكنك تفعيلها لكل محادثة على حدة.

ما نماذج الذكاء الاصطناعي التي يمكنها استخدام K8s Loki Troubleshooting؟

أي نموذج تربطه في TypingMind. مهارات الذكاء الاصطناعي عبارة عن تعليمات Markdown وليست شيفرة خاصة بمزود بعينه، لذا يمكن لكل من GPT وClaude وGemini وGrok والنماذج المحلية تحميل هذه المهارة عندما يتوافق الطلب معها.

كم نموذج ذكاء اصطناعي يمكنني استخدامه مع K8s Loki Troubleshooting؟

أي عدد تريده. ما دام النموذج يدعم المهارات، يمكنك استخدام K8s Loki Troubleshooting معه، سواء كان GPT أو Claude أو Gemini أو Grok أو DeepSeek أو Mistral أو Llama أو غيرها، وكل ذلك على TypingMind باستخدام مفاتيح API الخاصة بك.

هل مهارة الذكاء الاصطناعي K8s Loki Troubleshooting مجانية؟

نعم. نشرها k8s-servant على GitHub بموجب ترخيص Apache-2.0. لا تدفع إلا لمزود الذكاء الاصطناعي الخاص بك مقابل التوكنات التي تستخدمها.

ما هي مهارات الذكاء الاصطناعي؟

مهارة الذكاء الاصطناعي حزمة تعليمات قابلة لإعادة الاستخدام تعلّم نموذج الذكاء الاصطناعي كيفية تنفيذ مهمة محددة. وتتبع تنسيق Agent Skills المفتوح: ملف SKILL.md يتضمن اسمًا ووصفًا، إلى جانب أي نصوص برمجية أو قوالب أو ملفات مرجعية قد يحتاج إليها النموذج. لا يقرأ النموذج التعليمات إلا عندما يتوافق طلبك مع المهارة، لذا لا تترتب على المهارة المثبتة أي تكلفة حتى تُستخدم.

كيف تختلف مهارات الذكاء الاصطناعي عن الإضافات أو موصلات MCP؟

تمنح الإضافة أو موصل MCP النموذج أدوات جديدة يمكنه استدعاؤها، وهي شيفرة تُنفَّذ في مكان ما وتُرجع نتيجة. أما مهارة الذكاء الاصطناعي فتزوّد النموذج بالمعرفة ومنهجية العمل: كيفية التعامل مع مهمة، والخطوات التي ينبغي اتباعها، وما ينبغي أن تكون عليه المخرجات الجيدة. المهارات عبارة عن نصوص Markdown، لذا لا تحتاج إلى خادم أو مفتاح API أو بيئة تشغيل، وتعمل مع أي نموذج.

عرض الكل

أنشئ مساحة عملك للذكاء الاصطناعي الآن

اشترك في نشرتنا الإخبارية لتصلك أخبار الميزات الجديدة والهدايا القادمة 👇