/k8s-skills:k8s-prometheus-troubleshootingfrom k8s-skills
Diagnoses Prometheus scraping, rule loading, and alerting failures on Kubernetes. Investigates ServiceMonitors, PodMonitors, PrometheusRules, and operator resources using kubectl and Prometheus HTTP API, then proposes fixes.
Ships in k8s-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Find out why Prometheus does not scrape a target, does not load a rule, or does not alert, 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.
With the Prometheus Operator, a Prometheus custom resource selects
ServiceMonitors, PodMonitors, Probes, ScrapeConfigs and
PrometheusRules by label and namespace, and the operator turns them into
Prometheus' configuration. A ServiceMonitor selects Services by label and names one of
their ports. Something can go wrong at each step: the selection, the Service, the port,
the scrape itself.
The commands use placeholders: monitoring (where Prometheus runs), my-prometheus
(the Prometheus resource), my-namespace, my-app (the ServiceMonitor and its
Service) and my-rules. Replace them with the real names. Prometheus' HTTP API is
reached through the API server's service proxy on the governing Service
prometheus-operated (port name web); this needs get on services/proxy, which the
built-in view role does not have. If the proxy is forbidden, say so and ask the user
for the Targets page of the Prometheus UI.
Never read Secrets. The operator stores the generated Prometheus and Alertmanager
configuration in Secrets (prometheus-<name>, alertmanager-<name>-generated), and
the upstream troubleshooting guide decodes them. Do not: use the selection rules, the
operator's events and logs, and Prometheus' own API instead. For the same reason never
call Prometheus' /api/v1/status/config or Alertmanager's /api/v2/status: they return
that generated configuration (credentials masked, but webhook URLs and routes not).
Access to the service proxy covers the whole Service, so this rule is yours to keep.
down.Prometheus or Alertmanager resource is not Available, or its pods crash.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:
k8s-workload-troubleshooting.k8s-network-troubleshooting.k8s-storage-troubleshooting.Work through the steps in order. Stop when you have the cause and its evidence.
1. Read the Prometheus resource: its status, and which monitors and rules it selects.
kubectl get prometheuses -A
kubectl get prometheus my-prometheus -n monitoring -o jsonpath='{.spec.serviceMonitorSelector}{"\n"}{.spec.serviceMonitorNamespaceSelector}{"\n"}{.spec.podMonitorSelector}{"\n"}{.spec.ruleSelector}{"\n"}{.spec.ruleNamespaceSelector}{"\n"}{.status.conditions}{"\n"}'
2. Read the ServiceMonitor and compare it with the selection and with the Service.
kubectl get servicemonitors,podmonitors -A
kubectl get servicemonitor my-app -n my-namespace -o yaml
kubectl get service my-app -n my-namespace -o jsonpath='{.metadata.labels}{"\n"}{.spec.ports}{"\n"}'
kubectl get endpointslices -n my-namespace -l kubernetes.io/service-name=my-app
kubectl get namespace my-namespace --show-labels
3. Ask Prometheus what it scrapes: the jobs it has, the active targets with their health and last error, and the targets it dropped.
kubectl get --raw '/api/v1/namespaces/monitoring/services/prometheus-operated:web/proxy/api/v1/scrape_pools'
kubectl get --raw '/api/v1/namespaces/monitoring/services/prometheus-operated:web/proxy/api/v1/targets?state=active' | jq -r '.data.activeTargets[] | [.labels.job, .health, .scrapeUrl, .lastError] | @tsv'
kubectl get --raw '/api/v1/namespaces/monitoring/services/prometheus-operated:web/proxy/api/v1/targets?state=dropped' | jq -r '.data.droppedTargets[].discoveredLabels | [.__meta_kubernetes_service_name, .__meta_kubernetes_endpoint_port_name, .__address__] | @tsv'
A ServiceMonitor appears as the job serviceMonitor/<namespace>/<name>/<endpoint index>.
4. Read the operator's events and logs. The operator rejects invalid objects with an event and logs objects it skips.
kubectl events -n my-namespace --for servicemonitor/my-app
kubectl get deployments -A -l app.kubernetes.io/name=prometheus-operator
kubectl logs -n monitoring deployment/prometheus-operator --tail=200 | grep -i -E "skipping|rejected|my-app"
5. Open the matching reference and follow its steps:
| What you see | Reference |
|---|---|
| No job or no targets for a ServiceMonitor or PodMonitor, dropped targets | references/discovery.md |
Targets down: HTTP status, connection refused, timeouts, body size, content type | references/targets-down.md |
| A PrometheusRule not loaded, alerts not firing or not reaching Alertmanager | references/rules-and-alerts.md |
| The Prometheus resource not Available, pods OOMKilled, disk full, ingestion errors | references/prometheus-health.md |
What the common findings mean (Prometheus Operator 0.94, Prometheus 3.14):
serviceMonitor/<ns>/<name>/... in scrape_pools: the Prometheus does not
select the ServiceMonitor. Its labels do not match serviceMonitorSelector, or its
namespace does not match serviceMonitorNamespaceSelector. An empty selector ({})
matches everything; an unset (null) selector matches nothing for monitors and rules,
and only Prometheus' own namespace for the namespace selectors.endpoints[].port is not the name of one of the Service's ports (it
must be the port's name, not its number), or the Service has no ready endpoints.
The dropped target's __meta_kubernetes_endpoint_port_name shows the real port name.spec.selector matches no
Service, or namespaceSelector leaves the Service's namespace out.down with server returned HTTP status 404 Not Found: the path is
wrong (endpoints[].path, default /metrics). Other lastError values are in
references/targets-down.md.InvalidConfiguration, "<name>" was rejected due to invalid configuration: ...: the operator refused the object; the message says why.State the cause in one sentence, then the evidence you saw (the selector and labels, the port names, the target's health and error), then the proposed fix.
Show each fix to the user before running it: what it changes and how to undo it. Patching a ServiceMonitor, PodMonitor or PrometheusRule (labels, port, path) is reversible, so it goes under "Ask first" and runs only after the user says yes. Changing the Prometheus or Alertmanager resource (selectors, resources, retention), Alertmanager's configuration and anything with Secrets are never run by you: hand them to the user as proposed fixes. Monitors usually come from the app's Helm chart or manifests; fix them there too. Write each undo with the values you found.
Give a ServiceMonitor the label the Prometheus selects:
Ask first: the agent runs this only after the user approves it.
kubectl label servicemonitor my-app -n my-namespace release=my-prometheus
# Undo: kubectl label servicemonitor my-app -n my-namespace release-
Point a ServiceMonitor at the Service's real port name:
Ask first: the agent runs this only after the user approves it.
kubectl patch servicemonitor my-app -n my-namespace --type=json -p '[{"op": "replace", "path": "/spec/endpoints/0/port", "value": "http"}]'
# Undo: kubectl patch servicemonitor my-app -n my-namespace --type=json -p '[{"op": "replace", "path": "/spec/endpoints/0/port", "value": "metrics"}]'
Prometheus picks up the change by itself within a minute or two; check scrape_pools
and the targets again.
Checked against the Prometheus Operator 0.94 and Prometheus 3.14 documentation and source:
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub k8s-servant/k8s-skills --plugin k8s-skills31 skills in this plugin
/k8s-aks-troubleshootingUse when a problem is specific to Azure Kubernetes Service (AKS): a cluster or node pool in "Failed" state, an upgrade or scale that fails ("UpgradeFailed", "violate the pod's disruption budget", "QuotaExceeded", "AllocationFailed"), a LoadBalancer Service stuck at <pending> ("SyncLoadBalancerFailed", "AuthorizationFailed"), an Azure Disk or Files PVC that fails ("ProvisioningFailed", "volume node affinity conflict", "Multi-Attach error", "Mount error(13)"), workload identity errors ("AADSTS700016", "AADSTS70021"), CoreDNS edits that AKS reverts, "error dialing backend", Azure Policy denials, or API server access (authorized IP ranges, private clusters, kubelogin, "User does not have access to the resource in Azure"). Investigates with kubectl and read-only az commands, and proposes fixes. Reads first and asks before changing anything./k8s-api-troubleshootingUse when the Kubernetes API server itself refuses or fails a request, before any controller acts on it: "failed calling webhook", "admission webhook ... denied the request", "ValidatingAdmissionPolicy ... denied request", a ReplicaSet with FailedCreate and no pods, an APIService "False (ServiceNotFound)", "FailedDiscoveryCheck" or "MissingEndpoints", "unable to retrieve the complete list of server APIs", a namespace stuck in Terminating, "no matches for kind" or "ensure CRDs are installed first", "strict decoding error: unknown field", a conversion webhook failure, "You must be logged in to the server (Unauthorized)", 429 "too many requests", "etcdserver:" errors, "Request entity too large" or "metadata.annotations: Too long". Investigates with kubectl get, describe, events and the health endpoints, and proposes fixes. Reads first and asks before changing anything./k8s-argocd-troubleshootingUse when Argo CD does not deploy or update an application in Kubernetes: an Application that is OutOfSync, Unknown, Degraded, Missing or Progressing, a ComparisonError ("app path does not exist", "unable to resolve ... to a commit SHA"), an InvalidSpecError ("do not match any of the allowed destinations in project"), a sync that fails ("one or more objects failed to apply"), auto-sync that never runs, resources that stay OutOfSync after a sync, or ApplicationSets that generate nothing. Investigates with kubectl get, describe, events and logs, and proposes fixes. Reads first and asks before changing anything./k8s-autoscaling-troubleshootingUse when Kubernetes autoscaling does not scale as expected: a HorizontalPodAutoscaler whose TARGETS show "<unknown>", "missing request for cpu", "unable to get metrics for resource cpu" or "FailedGetResourceMetric", an HPA stuck at maxReplicas ("TooManyReplicas") or not scaling down, "Metrics API not available" from kubectl top, metrics-server not Ready, a KEDA ScaledObject that is not Ready ("ScaledObjectCheckFailed") or creates no HPA, KEDA scalers failing, two autoscalers on one workload, or a VerticalPodAutoscaler without recommendations. Investigates with kubectl get, describe, events, logs and top, and proposes fixes. Reads first and asks before changing anything./k8s-cert-manager-troubleshootingUse when cert-manager does not issue or renew a certificate in Kubernetes: a Certificate that stays READY False, a CertificateRequest that is Pending, Denied or Failed, an Issuer or ClusterIssuer that is not Ready ("Error getting keypair for CA issuer"), "Referenced \"Issuer\" not found", ACME Orders or Challenges stuck pending (HTTP-01, DNS-01, rate limits), a certificate that expired or did not renew, or "failed calling webhook \"webhook.cert-manager.io\"" when applying resources. Investigates with kubectl get, describe, events and logs, and proposes fixes. Reads first and asks before changing anything./k8s-cilium-troubleshootingUse when networking fails on a Kubernetes cluster that runs Cilium as its CNI: traffic between pods dropped or timing out after a CiliumNetworkPolicy or CiliumClusterwideNetworkPolicy, "Policy denied" drops in Hubble, DNS that stops resolving after an egress policy, HTTP 403 "Access denied" from an L7 rule, toFQDNs rules that do not match, pods stuck ContainerCreating with "unable to connect to Cilium agent", Cilium agent or operator pods not ready, CiliumEndpoints not ready, or IPAM exhaustion. Investigates with kubectl get, describe, events and logs, asks before running cilium-dbg or hubble inside the agent, and proposes fixes. Reads first and asks before changing anything.2 plugins in one repository ship this exact skill · first indexed Oct 27, 2026
Other plugins' skills for the same job